Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess redirect subdomain to root domain

I want to redirect this subdomain:

http://abc.domain-name.com

to a folder on the root domain that uses the same name:

http://www.domain-name.com/abc

This way, if I try to access the following file:

http://abc.domain-name.com/folder/file.html

It will go to:

http://www.domain-name.com/abc/folder/file.html
like image 373
Carrlos Boyd Avatar asked Nov 30 '12 02:11

Carrlos Boyd


1 Answers

Try this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.yourdomain\.com
RewriteRule ^(.*)$ http://www\.yourdomain\.com/subdomain/$1 [L]

(from http://systembash.com/content/simple-redirect-subdomain-to-a-directory/)

like image 69
nandhp Avatar answered Sep 17 '22 13:09

nandhp