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


Removing file extensions in .htaccess with wordpress

我有一个静态网站与 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]

试试这个

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