Serve pages based on domain by using htaccess

Posted by Safwan Erooth on Server Fault See other posts from Server Fault or by Safwan Erooth
Published on 2010-10-08T11:04:22Z Indexed on 2011/01/12 13:55 UTC
Read the original article Hit count: 109

Filed under:
|

I have a site mysite.com with different sections. There are several domains pointing to the same site. What I'm trying to achieve is.

Say if my site has the domains mysite.com, section1.com and section2.com.

If the user comes from section1.com the user should get mysite.com/section1/ it should not be redirected, it should be rewritten like this :

  1. mysite.com/section1/something should become section1.com/something
  2. mysite.com/section1/another should become section1.com/another

Same way if the user is coming from section2.com the content served should be mysite.com/section2/ and the domain rewritten like

  1. mysite.com/section2/something should become section2.com/something
  2. mysite.com/section2/another should become section2.com/another

© Server Fault or respective owner

Related posts about .htaccess

Related posts about url-rewriting