[英]Removing file extensions in .htaccess with wordpress
I have a static website running in conjunction with wordpress in the same dir, it all works fine. 我有一个与wordpress一起在同一目录中运行的静态网站,一切正常。 However, on the static pages that don't use wordpress I cannot seem to remove the .php file extensions my .htaccess file looks like this:
但是,在不使用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
I have tried adding this code as you usually would but it wont work: 我已经尝试像平时一样添加此代码,但无法正常工作:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Try this 尝试这个
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.