我使用以下.htaccess代码来填写我网页的php扩展程序:
RewriteEngine On
RewriteOptions inherit
Options +FollowSymlinks
Options -Multiviews
## hide .php extension
## To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ %{REQUEST_FILENAME}\.php [NC,L]
我可以转到localhost:80/site/page.php
,但当我尝试去localhost:8/site/page
时,XAMPP会给我一个"禁止访问"错误。这里发生了什么,我做错了什么?
答案 0 :(得分:0)
以这种方式尝试你的规则。
Options +FollowSymlinks -Multiviews
## hide .php extension
## To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/?$ $1.php [NC,L]