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

Apache .htaccess将域子域重定向到子目录,apache,.htaccess,redirect,Apache,.htaccess,Redirect,我们希望将子域重定向到子目录: customerservice.example.com至example.com/customerservice 如何在.htaccess文件中完成此操作 我假设: 重定向301 customerservice.example.com example.com/customerservice 我的假设正确吗?重定向没有将完整域作为第一个参数,您必须使用/: Redirect 301 / http://example.com/customerservice 但是,如果

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

customerservice.example.com至example.com/customerservice

如何在.htaccess文件中完成此操作

我假设:

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


我的假设正确吗?

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

Redirect 301 / http://example.com/customerservice
但是,如果此域位于另一个域的同一根上,并且您需要匹配域名,则必须使用以下内容:

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