Forum Moderators: phranque

Message Too Old, No Replies

Redirecting sites to subsites using htaccess

Setting different A and MX records and then using htaccess to redirect

         

deshg

1:58 pm on Jun 16, 2010 (gmt 0)

10+ Year Member



Hey everyone,

I'm not sure this is exactly the right place for all of my query, so apologies if this is in the wrong place! I am setting up a template website builder whereby users select a theme and add pictures/text etc and it produces a customised site. If they like it they can buy it and their purchase includes a domain name (and possibly email hosting). All sites are temporarily accessible via www.mydomain.com/page.php?username=username. Because all sites work off the same template i do not want to setup hosting for each one as if i have to change the template i will have to do this for every site indvidually. Neither do i (ideally) want to use framed url forwarding as this will screw up the SEO. What makes it more tricky is people will want their own email addresses so i have to setup email hosting individually and link the domain to that.

As a result here is my question (!): Am i right in thinking that i can set the A Record for the new domains to point to the ip address of mydomain.com and point the MX records to the (different) email host provider. Then setup an htaccess file in the root of mydomain.com to internally rewrite the url (if the entry domain is anything other than mydomain.com) to be www.mydomain.com/page.php?domain=entrydomainname.

I think this makes sense, but i would be massively grateful if anyone more knowledgable than me could provide any advice?

Thanks so much for your help as ever everyone,

Dave

jdMorgan

1:51 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a typical application of "rewrite domain name to script" rules previously discussed here, which can be found with a search for "rewrite domain name to script rewritecond http_host -subdomain [google.com]" and similar.

Note that some of the results have to do with related, but not identical rewriting techniques. However, it is important to understand the concepts involved, so these threads are still useful -- It's not likely you'll find 'code that does exactly what you need' posted anywhere, so even related examples can be used to learn the techniques.

Those threads, along with the resources cited in our Apache Forum Charter, should go a long way toward getting you on the right path.

Jim