我的.htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
</IfModule>
你好,目前我的系统工作正常,我可以在最后没有.php的链接,但我想更进一步,如果有人要手动输入.php,如果链接是www.example.com/account
将其更改为www.example.com/account.php会产生404错误吗?
这可能吗?
非常感谢,我非常感谢我收到的任何回复!
答案 0 :(得分:0)
您可以在RewriteEngine on
行:
RewriteEngine On
# To externally redirect /dir/file.php or /dir/file.html to /dir/file
RewriteCond %{THE_REQUEST} \s/+(.+?)\.(?:php|html?)[\s?] [NC]
RewriteRule ^ - [R=404,L]
# your existing rules go below this
这将为www.example.com/account.php
或www.example.com/account.html