RewriteEngine文件夹重定向

时间:2011-12-28 10:12:53

标签: asp.net rewrite load-balancing

我正在编写重写规则,将所有网址从mysite.co.uk/en/重定向到mysite.co.uk/。我写了以下内容。只是希望有人确认它对我来说是正确的,并建议可能的改进,如果有的话。

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

2 个答案:

答案 0 :(得分: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.

答案 1 :(得分: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/