I want all traffic to go to:
|
V
I can use .htaccess or maybe something in PHP, I'm using zend framework. Please note I also have:
thx
I want all traffic to go to:
|
V
I can use .htaccess or maybe something in PHP, I'm using zend framework. Please note I also have:
thx
This rules will preserve the complete uri
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(domain.com)$ [NC]
RewriteRule ^(.*)$ http://main.%1/$1 [R=301,L,QSA]
PS: I cannot think up how to make second line more portable without explicit domain specification. I will appreciate someone who can correct me.
The server-side solutions seem a little unnecessary when the Domain Name Server protocol is designed to handle redirects exactly like these. Path info and POST variables are preserved transparently.
If you have access to the DNS records for your website, it is best to use a CNAME record to redirect users to the proper domain name.
The CNAME points people looking for one domain (e.g. site.com) to another (e.g. main.site.com). This is all done without any work on your server.
Simply add two records to your CNAME records pointing:
domain.com => main.domain.com
www.domain.com => main.domain.com
If your current DNS provider does not provide this, try using ZoneEdit, who have worked very well for us in the past.
What you are trying to do is a functionality of web server. So let the webserver handle the request. So the most efficient way is using .htaccess redirect directives. Doing it using PHP is an inefficient way.