[英]Redirecting subdomain to another subdomain, as variable
我已经阅读了有关.htaccess
所有教程,但仍然不知道:
.htaccess
现在看起来是这样的:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*domain.com$ [NC]
RewriteRule ^(.*)$ http://anotherdomain.com/ [R=301,L]
我想重定向:
subdomain.domain.com
至:
subdomain.anotherdomain.com
未指定子域。
因此,它应该重定向:
subdomain1.domain.com
至:
subdomain1.anotherdomain.com
和:
subdomain2.domain.com
至:
subdomain2.anotherdomain.com
和:
subdomain3.domain.com
至:
subdomain3.anotherdomain.com
等等...
是否可以将subdomainx
传递到$1
,然后重定向到$1.anotherdomain.com
?
您可以使用:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$ [NC]
RewriteRule ^ http://%1.anotherdomain.com%{REQUEST_URI} [R=301,L,NE]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.