.htaccess 将index.php重定向到/

2024-02-21

我想隐藏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 仍然显示


尝试一下,这对我有用!确保你有AllowOverride All在httpd.conf中设置

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]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

.htaccess 将index.php重定向到/ 的相关文章

随机推荐