首页 文章

使用wordpress删除.htaccess中的文件扩展名

提问于
浏览
1

我在同一个目录中有一个与wordpress一起运行的静态网站,一切正常 . 但是,在不使用wordpress的静态页面上,我似乎无法删除.php文件扩展名,我的.htaccess文件如下所示:

# BEGIN WordPress
<IfModule mod_rewrite.c>
ErrorDocument 404 /index2.php
RewriteEngine On
RewriteBase /index.php/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

#Alternate default index page
DirectoryIndex index2.php

ErrorDocument 404 http://example.com/index2.php

我已经尝试像往常一样添加此代码,但它不会工作:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

1 回答

  • 0

    试试这个

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php                       [L]
    

相关问题