2013-10-23 223 views
2

我想将旧域名重定向到新域名。其实我的网站是在www_olddomain_pl/index.php和英文版下www_olddomain_com/index_en.phpHtaccess - 301域名重定向

我想要做什么?

olddomain_pl -> www_new_pl 
www_olddomain_pl -> www_new_pl 
odldomain_com -> www_new_com 
www_olddomain_com -> www_new_com 

并且从索引重定向到没有索引。 我其实有什么?

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^(.*)olddomain_pl(.*) [NC] 
RewriteRule ^(.*)$ http://www_olddomain_pl/$1 [R=301,L] 
RewriteRule ^index.php$ http://www_new_pl/ [R=301,L] 

RewriteCond %{HTTP_HOST} ^(.*)olddomain_com(.*) [NC] 
RewriteRule ^(.*)$ http://www_new_com/$1 [R=301,L] 

我不知道该怎么做。

编辑: 还有一个: 其实我已经版本二我的网站 - 波兰语和英语。 波兰语版本正在olddomain_pl/index.php文件 英文版本正在olddomain_pl/index_en.php

我想有:下new_pl 英文版 波兰语版本下new_com

所以我需要从加www重定向与www和从index.php或index_en.php到没有。

回答

3

您可以使用此规则:

RewriteEngine On 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index_en\.php [NC] 
RewriteRule^http://www.live-dent.com/ [R=301,L,NC] 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php [NC] 
RewriteRule ^/[R=301,L,NC] 

RewriteCond %{HTTP_HOST} live-dent\.pl$ [NC] 
RewriteRule^http://www.livedent.pl%{REQUEST_URI} [R=301,L] 

编辑:按评论:

RewriteCond %{HTTP_HOST} live-dent\.com\.pl$ [NC] 
RewriteRule^http://www.livedent.pl%{REQUEST_URI} [R=301,L] 
+0

非常感谢你!这很好! – user2911046

+0

很高兴知道,请考虑将其标记为“已接受”。 – anubhava

+0

对不起,它不起作用... 如果我写:olddomain_pl /在输入的东西我是www_olddomain/somethingsomething 有些事情是错的。 其他: 其实我有两个版本的网站 - 波兰语和英语。 波兰语版本正在olddomain_pl/index.php文件 英文版本正在olddomain_pl/index_en.php 我想有:下new_pl 英文版 波兰语版本下new_com 所以我需要从whitout WWW重定向到白衣www和从index.php或index_en.php不能。 – user2911046