[英]Redirect URLs from many subdomains using .htaccess
I am changing my website structure and I need to redirect 301 many URLs from many subdomains.我正在更改我的网站结构,我需要从许多子域重定向 301 个 URL。 I have many subdomains, How can I do that in one .htaccess ?
我有很多子域,如何在一个 .htaccess 中做到这一点? Redirect both :
重定向两者:
ch.mydomain.com/coffee to www.mydomain.com/de_ch/coffee ch.mydomain.com/coffee到www.mydomain.com/de_ch/coffee
it.mydomain.com/coffee to www,mydomain.com/it_IT/coffee it.mydomain.com/coffee到www,mydomain.com/it_IT/coffee
EDIT : Some URLs have folder and some have different name : exm :编辑:有些网址有文件夹,有些网址有不同的名称:exm:
ch.mydomain.com/coffetype/nespresso to www.mydomain.com/de_ch/nespressocafe ch.mydomain.com/coffetype/nespresso到www.mydomain.com/de_ch/nespressocafe
Thank you谢谢
You may use these redirect rules:您可以使用这些重定向规则:
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.