我想隐藏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]
解决方法
试试吧,它对我有用!确保在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]