Search code examples
.htaccesshttp-redirectsubdomain

Point domain to subdomain folder with same url


I have a domain

http://www.example.biz/

I developed a site and put the code in a sub folder on this domain for example, the site is at

http://www.example.biz/site

now, I wanted to point my main domain to this folder so that when user visits example.biz he actually sees example.biz/site and for that, I added the below lines in .htaccess

RedirectMatch ^/$ /site/

it works perfectly however, the url user sees is

http://www.example.biz/site

I do not want that, I wanted user to only see http://www.example.biz as URL but this domain should point to the sub folder invisibly. How should I do that ?


Solution

  • I found a simpler solution,

    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [NE,R=301,L]
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.biz$
    RewriteRule !^site/ /site%{REQUEST_URI}  [L]