linux – .htaccess redirect index.php到/

前端之家收集整理的这篇文章主要介绍了linux – .htaccess redirect index.php到/前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想隐藏index.PHP页面,只显示域名.

这可能与.htaccess一起使用吗?

RewriteRule ^index\.PHP/?$/ [L,R=301,NC]

还尝试过:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.PHP HTTP/
RewriteRule ^index.PHP$http://example.com/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.PHP [L]

index.PHP仍然显示

解决方法

试试吧,它对我有用!确保在httpd.conf中设置了AllowOverride All
RewriteEngine On 

    RewriteCond %{REQUEST_URI} index\.PHP
    RewriteRule ^(.*)index\.PHP$/$1/ [R=301,L]

您的规则中存在正则表达式问题,我修改了您的规则并且它适用于我:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} index\.PHP
RewriteRule ^index\.PHP$http://example\.com/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index\.PHP [L]
原文链接:https://www.f2er.com/linux/393788.html

猜你在找的Linux相关文章