重定向规则到主页

时间:2017-12-14 09:43:25

标签: .htaccess redirect mod-rewrite web

我应该在.htaccess文件中写什么规则,让重定向工作从http://site.ru/index.php/ru - 到http://site.ru/ru/

2 个答案:

答案 0 :(得分:1)

这应该有用。

RewriteEngine On

RewriteRule ^ index.php / ru http://site.ru/ru/ [R = 301,L]

答案 1 :(得分:0)

在apache中启用重写模块,然后将以下行添加到.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

OR

RewriteBase /
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
相关问题