我想隐藏 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]
关于linux - .htaccess 将 index.php 重定向到/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14733988/