簡體   English   中英

我需要將首頁重定向到一個域,將其余頁面重定向到另一個域

[英]I need to redirect homepage to one domain and rest of the pages to another domain

我需要將我的域www.example.com重定向到www.new-example.com,但僅當用戶請求root時才需要。 如果它是一個子頁面,那么我需要它去一個子域。

例如:www.example.com/-> www.new-example.com/ www.example.com/p1.html-> example.new-example.com/p1

謝謝。

您可以在DOCUMENT_ROOT/.htaccess文件中使用以下代碼:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC]
RewriteRule ^/?$ http://www.new-example.com/ [L,R=302]

RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ http://example.new-example.com/$1 [L,R=302,NE]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM