我的网站上有一个.htaccess文件的根目录,用于隐藏URL中的.php部分。 它很棒。但它在media.php文件上失败了。 当我调用例如domain.com/idea.php的URL时,它会返回到domain.com/idea [正如我所料。]。 但对于media.php,它返回到domain.com/media/ [并显示403禁止页面] 我不知道它将如何发生。
here is my code on .htaccess file:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## don't touch /forum URIs
RewriteRule ^forums/ - [L,NC]
## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]