简体   繁体   English

将子域重定向到子目录

[英]Redirect sub domain to sub directory

I want to redirect the the subdomain to subdirectory but not working. 我想将子域重定向到子目录,但是不起作用。 Here is my efforts. 这是我的努力。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^name\.site_url
RewriteRule ^(.*)$ http://site_url/name/$1 [L,R=301]

Try this: 尝试这个:

RewriteCond %{HTTP_HOST} ^sub\.
RewriteRule ^(.*)$ http://your_domain/sub/$1 [R,L]

Instead sub in RewriteCond and RewriteRule you can place whatever you want 代替子在RewriteCond和RewriteRule中,您可以放置​​任何您想要的东西

Btw, RewriteCond %{HTTP_HOST} ^sub\\.my\\.domain$ also works for me. 顺便说一句, RewriteCond %{HTTP_HOST} ^sub\\.my\\.domain$也对我RewriteCond %{HTTP_HOST} ^sub\\.my\\.domain$ So, check your site url. 因此,请检查您的网站网址。 Or give more info (at least, what happened in apache error.log). 或提供更多信息(至少,apache error.log中发生了什么)。

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

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