重定向/index.php - wordpress

时间:2013-06-12 14:37:32

标签: php wordpress .htaccess

我希望如果有人链接到我的网站,请说:www.bla.com/index.php,他将重定向到www.bla.com。换句话说 - 删除index.php。

这是我的.htaccess文件:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^bla\.com$ [NC]
RewriteRule ^(.*)$ http://www.bla.com/$1 [L,R=301]

如果有人获得链接:www.bla.com/camera/index.php - 它将重定向到www.bla.com/camera /.

目前,网站本身效果很好,没有index.php,但我想删除index.php,如果有人来自extern链接。

4 个答案:

答案 0 :(得分:2)

这篇文章用WordPress标记。所有你正在寻找和做的事情(规范域名,没有index.php的规范网址)已经内置到WordPress中,至少自WP 3.0开始永久链接开启后......查看canonical redirects - 你会在那里找到逻辑。

答案 1 :(得分:0)

尝试那样;

RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} ^bla\.com$ [NC]
RewriteRule ^(.*)$ http://www.bla.com/$1 [L,R=301]

RewriteRule ^index.php/(.*)$ /$1 [R=302,L]
RewriteRule ^(.*)$ index.php?/$1 [L]

答案 2 :(得分:0)

我相信即使涉及外部链接,OP也希望阻止使用index.php。遵循其他问题的建议。试试这个。

RewriteRule ^(.*)/index.php$ http://www.bla.com/$1/ [L,R=301]

答案 3 :(得分:0)

试试这个

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
相关问题