Forum Moderators: phranque
The following Mod_rewrite code redirects the domain 'example.com' to 'quux-foo.org'. But the browser address bar URL displays 'quux-foo.org' :
RewriteEngine On
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^example.com/$ [NC,OR]
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^www.example.com/$ [NC]
RewriteRule ^(.*)$ [quux-foo.org...] [L]
Can you please tell me how to keep the address bar URL unchanged when the redirection goes fine to quux-foo.org?
Vincent
[edited by: jdMorgan at 12:13 pm (utc) on Nov. 6, 2006]
[edit reason] Examplified [/edit]
Do you have control over both servers? Is one a subdomain or a directory on somebody else's server? (i.e. a blog, etc.?)
If you do a redirect from domain A, all it does is send the browser to domain B. Domain B is still domain B. You want to say "go to domain B, and pretend it is domain A".
Think of the implications of what you are trying to do: if it worked, anybody could hijack your website and make it look like it was theirs.
Why don't you do it the other way around? Redirect from domain B to domain A?
You have to decide which one you want as your "primary" domain. Once you decide, do the redirect from the "secondary" domain to the "primary" one.
If you want common content on both, simply set your "A" records for both domains to point to the same server. You need to be careful to only use relative references in your internal links, and be careful of any stray references to the site name in your HTML files. (You can use server-side includes to deal with this.)
Another way is to "frame" the second site, but this is a poor substitute. This is commonly done by people who have, say, a subdomain on a blogging site, and want to use their own domain. Very dependent on how the blogging software does it's internal links, etc.
I want domainA.com show the content of domainB.com . Acutally I am not experecing any difficuties with hosting or redirecting the domains. I just want the visitors of my old site go to domainA.com go to domainB.com. I want to accomplish this just using mod rewrite code rather editing the zone file of the domain.
Thank you,
Vincent
[edited by: jatar_k at 12:28 am (utc) on Nov. 21, 2006]
[edit reason] no urls thanks [/edit]
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^.*example\.com [NC]
RewriteRule ^(.*)$ [quux-foo.org...] [P]
[edited by: jatar_k at 12:28 am (utc) on Nov. 21, 2006]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*example.com$ [NC,OR]
RewriteRule ^(.*)$ [quux-foo.org$1...] [R=301,L,QSA]
If you are simply trying to redirect all users from domainA.com to domainB.com then it is simple
But then he wants the URL in the browser bar to read domainA.com... Does not compute... :)
I'm still not quite understanding. Please confirm, this is what I think you want:
- domainA is your OLD site.
- domainB is your NEW site.
- You want users who go to domainA to be redirected to domainB.
- But once they get to domainB, you want domainB to masquerade as domainA. (Show domainA in the browser bar.)
Is this correct?
If so, you can't accomplish this by making changes only on domainA's website.
What do you want the user to see if they navigate directly to domainB?
It sounds to me like you are just changing web hosts. Why not just change the A record?