How to redirect from a subdomain to a subfolder using .htaccess

爱⌒轻易说出口 提交于 2019-11-28 12:49:04

You need to change your RewriteRule to include the new domain you're trying to redirect too, otherwise it will treat the beginning / as a new path on the current domain.

RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com
RewriteRule ^(.*)$ http://domain.com/subfolder/$1 [R=301]

Should do the trick.

James Nguyen

This will work for you:

RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$
RewriteRule ^ http://domain.com/subfolder/$1 [L,R]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!