[英]redirect certain pages to its equivalent in another domain, otherwise redirect to its homepage
[英]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.