Forum Moderators: phranque

Message Too Old, No Replies

Redirecting to a different domain

         

guymal

3:02 pm on May 16, 2006 (gmt 0)

10+ Year Member



A bit of background:
I have an active forum setup on my server under forum.originaldomain.com.
I now have a new domain name that is supposed to replace originaldomain. The new domain is setup in the DNS to point to my server under forum.newdomain.com.

What I want to do is setup my server so that all requests to the forum under the new domain will be rewritten to the old domain (that way the old links will continue to work and the new domain will work simultaneously).
For example: a request to [forum.newdomain.com...] will be rewritten to [forum.olddomain.com...]

I don't have access to httpd.conf but I do have .htaccess and I know that mod_rewrite works properly.

Anybody know how I can do this?

TIA!

webdoctor

7:29 am on May 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]

where www.example.com is your new domain? This assumes you want to send a 301 Moved Permanently code.

guymal

11:17 am on May 17, 2006 (gmt 0)

10+ Year Member



That's kinda what I want only I want the URL to be rewritten internally but have the domain name in the address bar not change.
So a request to [forum.newdomain.com...] will stay [forum.newdomain.com...] in the browser but internally it will be rewritten to [forum.olddomain.com...]

jdMorgan

4:35 pm on May 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You cannot 'change domains' by rewriting within a server. You'll need an external redirect, which handshakes with the client and results in a browser address bar update, or a proxy throughput, which makes the requested URL a proxy for the actual URL, with all requests for the requested resource passing through both servers.

However, if you simply wish the old domain links to continue to work, then a 301 Moved Permanently redirect from the old domain URLs to the new domain URLs is the recommended solution for best user experience and proper search engine indexing/ranking.

Redirecting the other way, from the new domain to the old domain, may seriously confuse the search engines and cause problems when the time comes that you want to take the new domain live. You will have been telling them for weeks or months that the new domain should be ignored and requests made instead to the old domain. Therefore, they may continue to ignore the new domain for quite some time, even after the redirect is removed.

The address bar should reflect the actual URL of a resource. It is often a very good sign that the wrong approach is being used when the phrase "force the address bar" appears in a post. Either that, or something untoward is being attempted. Apache is pretty good about not allowing the user to be confused about actual URLs. And note that URLs are not at all the same thing as 'files' -- Internal filepath rewrites are not usually problematic from a user-security standpoint, and so Apache does not constrain them. Although you're not really trying to fool anyone in this application, odds are that another approach will work better. The 'signalling' between clients and servers is well-defined in the HTTP protocol [w3.org], and strictly following that standard will lead to the correct solution (See request and response codes).

Jim