简体   繁体   中英

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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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