2012-03-06 61 views
0

WordPress博客可通過mod_rewrite http://xyz.de聯繫。 在未來,這個博客將達到http://blog.xyz.de。這不是一個挑戰,但是舊地址必須轉發到實際的文章地址。.htaccess使用新網站轉發

http://xyz.de/YYYY/MM/DD/titel/必須轉發到http://blog.xyz.de/YYYY/MM/DD/titel/

爲了使事情更加複雜,在根域(http://xyz.de)必須可以訪問新頁面。 這使用GET參數進行導航。例如http://xyz.de/index.php?site=home

有什麼辦法可以實現這個嗎?

回答

1

這是一個相當瑣碎的重寫和重定向:

RewriteEngine On 
# If the domain is xyz.de... 
RewriteCond %{HTTP_HOST} ^xyz.de 
# And the requested file is not /index.php (for the special case) 
RewriteCond %{REQUEST_FILENAME} !/(index\.php)?$ 
# Redirect to the new domain, appending any existing query string 
RewriteRule ^(.*)$ http://blog.xyz.de/$1 [L,R=301,QSA] 
+0

謝謝! 但是,當我去http://xyz.de時,我會轉發到http://blog.xyz.de。 只有當我輸入http://xyz.de/index.php時,才能找到正確的頁面。 – 2012-03-06 23:16:42

+0

@JulianHinderer看到上面的變化,第二個'RewriteCond'。我認爲應該照顧它 – 2012-03-07 02:47:07

+0

再次感謝您!完美的作品。 – 2012-03-07 23:55:06