![](/img/trans.png)
[英]Redirect all wild card subdomains and subdomain urls to the root domain and root domain urls using htaccess
[英]Redirect URLs from many subdomains using .htaccess
我正在更改我的网站结构,我需要从许多子域重定向 301 个 URL。 我有很多子域,如何在一个 .htaccess 中做到这一点? 重定向两者:
ch.mydomain.com/coffee到www.mydomain.com/de_ch/coffee
it.mydomain.com/coffee到www,mydomain.com/it_IT/coffee
编辑:有些网址有文件夹,有些网址有不同的名称:exm:
ch.mydomain.com/coffetype/nespresso到www.mydomain.com/de_ch/nespressocafe
谢谢
您可以使用这些重定向规则:
RewriteEngine On
# specific rules
RewriteCond %{HTTP_HOST} ^ch\. [NC]
RewriteRule ^coffetype/nespresso/?$ http://example.com/de_ch/nespressocafe [L,NC,R=301]
# generic rules that have same URIs after redirect
RewriteCond %{HTTP_HOST} ^ch\. [NC]
RewriteRule ^ http://example.com/de_ch%{REQUEST_URI} [L,NE,R=301]
RewriteCond %{HTTP_HOST} ^it\. [NC]
RewriteRule ^ http://example.com/it_IT%{REQUEST_URI} [L,NE,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.