2011-12-28 77 views
1

我正在编写一个重写规则,将所有url从mysite.co.uk/en/重定向到mysite.co.uk/。我有以下我写的。只是希望有人确认它对我来说是正确的,并建议可能的改进(如果有的话)。RewriteEngine文件夹重定向

Options +FollowSymlinks 
RewriteEngine on 
RewriteOptions MaxRedirects=10 
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.co\.uk$ 
RewriteRule ^en/(.*)$ http://www\.mysite\.co\.uk/$1 [NC,R=301] 
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com\.au$ 
RewriteRule ^en/(.*)$ http://www\.mysite\.com\.au/$1 [NC,R=301] 
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.co\.nz$ 
RewriteRule ^en/(.*)$ http://www\.mysite\.com\.nz/$1 [NC,R=301] 
RewriteEngine off 

回答

0

经过大量的研究证明,我应该能够做到这本:

redirect 301 /en/ http://www.mywebsite.co.uk/

redirect 301 /en/ http://www.mywebsite.com.au/

redirect 301 /en/ http://www.mywebsite.co.nz/

这是我们重定向要www.mywebsite.co.uk/en/mywebsite.co.uk/en/www.mywebsite.co.uk/

0

使用下面的代码

Options +FollowSymlinks 
RewriteEngine on 
rewritecond %{http_host} ^domain.com [nc] 
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] 

Please REPLACE domain.com and www.newdomain.com with your actual domain name. 
+0

我注意到任何网址,你改变了^恩/(.*)$到^(。*)$,这并不占的事实,我在负载平衡器上设置此规则,并且/ en /文件夹不是由cms创建的逻辑文件夹。 – Anicho 2011-12-28 10:35:30

相关问题