通过htaccess将子域重定向到子目录
问题描述:
我一直在尝试通过 htacess 将子域重定向到子目录..
I've been trying to redirect a subdomain to a subdirectory through htacess..
我有一个域可以说 sub.domain.com
和目录 domain.com/site/
我想将 sub.domain.com 重定向到 domain.com/site 而不更改任何 url,只需以 SEO 友好的方式重定向.
I have a domain lets say sub.domain.com
and the directory domain.com/site/
I want to redirect sub.domain.com to domain.com/site not changing any url, simply redirecting in a SEO friendly way.
我尝试了重定向 301 规则,但似乎没有奏效.
I've tried a redirect 301 rule but it doesn't seem to have worked.
答
在您的 .htaccess 中试试这个:
Try this in your .htaccess:
RedirectMatch 301 wiki.comp.tf(.*) comp.tf/wiki$1
如果这不起作用,另一种选择是:
If that does not work, an alternative option is:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^wiki.comp.tf
RewriteRule ^(.*)$ http://comp.tf/wiki$1 [L,NC,QSA]
使用真实姓名的一些潜在选项:
Some potential options for you using actual names:
Redirect 301 wiki.comp.tf comp.tf/wiki