dongqianzong4275
dongqianzong4275
2015-11-09 14:17
浏览 23
已采纳

将子域重定向到子目录

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]
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dovzrfr0506
    dovzrfr0506 2015-11-09 14:42
    已采纳

    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

    Btw, RewriteCond %{HTTP_HOST} ^sub\.my\.domain$ also works for me. So, check your site url. Or give more info (at least, what happened in apache error.log).

    点赞 评论

相关推荐