简体   繁体   English

301将所有子域URL重定向到特定URL

[英]301 Redirect all subdomain URL's to specific URL

My client had a bunch of location specific subdomain sites, but we've consolidated these into one site and created individual office pages. 我的客户有一堆特定于位置的子域站点,但是我们将它们合并到一个站点中并创建了单独的办公页面。 Can anyone help me go about 301 redirecting all location1.example.com URL's to example.com/location1 etc? 有人可以帮我解决301,将所有location1.example.com URL重定向到example.com/location1等吗?

Try this in root/.htaccess 在root / .htaccess中尝试一下

RewriteEngine On

RewriteCond %{HTTP_HOST} ^location1\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/location1/$1 [NC,L,R]

You can give this a try in your .htaccess in the document root. 您可以在文档根目录的.htaccess中尝试一下。 This will convert any of your subdomains into subfolder. 这会将您的任何子域转换为子文件夹。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^((?!www).+)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/%1/ [R=301,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM