2013-10-24 101 views
1

我想將舊域名重定向到新域名。我有兩個版本的網站 - 波蘭語和英語。我有的域名是:live-dent.pl,live-dent.com,live-dent.com.pl和livedent.pl。 我想重定向:高級htaccess - 301域名重定向

  • (WWW)live-dent.pl/index.php,(WWW)live-dent.com/index.php,(WWW)live-dent.com。 PL/index.php的和livedent.pl/index.php到 www.livedent.pl(無破折號),
  • (WWW)live-dent.pl/index_en.php,(WWW)在線 - dent.com/index_en.php,(www。)live-dent.com.pl/index_en.php和livedent.pl/index_en.php到 www.live-dent.com(與破折號)。

爲此,我想將404錯誤重定向到自定義頁面。此文件路徑的波蘭語版本是:

  • www.livedent.pl/404.php和
  • www.live-dent.com/404_en.php英文版本(此文件不存在,現在)。

,我現在已經將代碼(感謝@anubhava)是:

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] 

規則的ErrorDocument 404 /404.php不起作用。

回答

1

假設所有這些域共享相同的文檔根:

RewriteCond %{HTTP_HOST} ^(www\.)?live-dent\.(pl|com|com\.pl)$ [OR,NC] 
RewriteCond %{HTTP_HIST} ^livedent\.pl$ [NC] 
RewriteCond %{THE_REQUEST} \ /+index\.php 
RewriteRule^http://www.livedent.pl/ [L,R=301] 

RewriteCond %{HTTP_HOST} ^(www\.)?live-dent\.(pl|com|com\.pl)$ [OR,NC] 
RewriteCond %{HTTP_HIST} ^livedent\.pl$ [NC] 
RewriteCond %{THE_REQUEST} \ /+index_en\.php 
RewriteRule^http://www.live-dent.com/ [L,R=301] 
+0

非常感謝你!你知道爲什麼規則:ErrorDocument 404/404.php不起作用? – user2911046

+0

@ user2911046你有其他規則嗎? –

+0

不,我不知道。現在我有: RewriteEngine敘述在 的RewriteCond%{THE_REQUEST}^[AZ] {3,} \ S/+ index_en \ .PHP [NC] 重寫規則^ http://www.live-dent.com/ [R = 301,L,NC] 的RewriteCond%{THE_REQUEST}^[AZ] {3,} \ S/+索引\ .PHP [NC] 重寫規則^/[R = 301,L,NC] 的RewriteCond% {HTTP_HOST}活凹痕\特等$ [NC] 重寫規則^ HTTP://www.livedent.pl% {REQUEST_URI} [R = 301,L] 的ErrorDocument 404 /404.php 我不現在可以訪問服務器,所以這是舊的代碼。您確定最後一行可以正常使用您的代碼版本嗎? – user2911046