我一直在尝试用这段代码从我的URL中删除.php结尾,但它不起作用。这是我的.htaccess文件:
# Apache Rewrite Rules
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Add trailing slash to url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ $1/ [R=301,L]
# Remove .php-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/$ $1.php
# End of Apache Rewrite Rules
</IfModule>我将该文件放入我的public_html文件夹中。由于某些原因,它仍然显示example.com/index.php而不是example.com/index。有什么线索吗?
发布于 2016-07-24 11:50:11
尝尝这个
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]https://stackoverflow.com/questions/38548452
复制相似问题