.htaccess将域子域重定向到子目录

时间:2013-07-29 16:15:35

标签: apache .htaccess redirect

我们想将子域重定向到子目录:

customerservice.example.com到example.com/customerservice。

如何在.htaccess文件中完成?

我假设:

重定向301 customerservice.example.com example.com/customerservice

我的假设是否正确?

1 个答案:

答案 0 :(得分:0)

重定向不会将完整域作为第一个参数,您必须使用/

Redirect 301 / http://example.com/customerservice

但是,如果此域名位于另一个域的同一根域,并且您需要匹配域名,则必须使用以下内容:

RewriteCond %{HTTP_HOST} ^customerservice\.example\.com$
RewriteRule ^(.*)$ http://example.com/customerservice/$1 [R=301,L]
相关问题