Forum Moderators: phranque

Message Too Old, No Replies

301 Redirect (to other domain) without changing the url

mod_rewrite, 301, redirect, other domain

         

valgreen

12:22 pm on Nov 11, 2011 (gmt 0)

10+ Year Member



Hi,
I am trying to do a 301 redirect (from one subdomain to other domain's subdomain) and I would need to do that without changing the URL in the address bar.

Here is the rule I have at .htaccess of subdomain.domain1.com:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://subdomain.domain2.com/$1 [R=301,L]


Result:
When I invoke subdomain.domain1.com it is changing the URL to
http://subdomain.domain2.com/


Many thanks

More info:
- I tried to use DNS CNAME redirect but it was opening
http://domain2.com/ 
and not
http://subdomain.domain2.com/ 

- I tried
<?php header( 'Location: http://subdomain.domain2.com/', true, 301 ); ?>
but it changed URL

g1smd

7:58 pm on Nov 11, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A redirect by definition will change the URL in the address bar because the site tells the browser to make a new request for a different URL.

You need to set your RewriteRule to act as a proxy or to rewrite the request not serve a redirect.