繁体   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