Is there a way I could achieve redirecting to another site, without losing the original URL? So, what we'd want to achieve is to be able to access:
somesite.com/some/url -> someothersite.com/some/url
but we'd like to retain somesite.com/*.
In other words, we'd want to access every URL of someothersite.com via somesite.com.


Are you actually looking for a redirect, or to have that other site's content appear under your original URL (more proxying)? I'll assume that the other server is your content and either internal/backend or if public you're aware of the negative SEO implications. If someothersite.com is not your site and content, you probably shouldn't be doing this.

You'll need to have mod_proxy and mod_rewrite running, which is likely uncommenting the lines mentioning it if not already done.

Then in the somesite.com config:
RewriteEngine on
RewriteRule /some/url(.*) http://someothersite.com/some/url$1 [P,L]


If you're trying to redirect just a subdirectory of the server, you can use mod_rewrite like this:

RewriteCond %{REQUEST_URI} /some/url [NC]
RewriteRule ^(.*)$ other.example.com/$1 [R]

If your trying to show the content of the other site without the user seeing the other url, you'll need both mod_rewrite and mod_proxy

RewriteCond %{REQUEST_URI} /some/url [NC]
RewriteRule ^(.*)$ http://other.example.com/$1 [P]

Other configuration steps may be necessary for mod_proxy, depending on your environment.

Apache's Advanced mod_rewrite Guide may be of benefit.


I'd just throw in a file that simply redirects the user with an HTML meta-refresh, or if you want to redirect the user in the most accepted way possible, throw in a 301 redirect rule in an .htaccess file somewhere on the site.


Redirect 301 /some/url http://newsite.com/some/url
  • A meta-refresh would affect the www.example.com page as well; and you'd have to add it to every single page in the whole site for it to work correctly. Adding a redirect in an .htaccess file wouldn't work if there's no default record for example.com. – Chris S Jul 14 '10 at 3:12
  • Hm, good point. I've probably read the question wrong: I see that he wants to redirect EVERY URL from somesite.com to someothersite.com; however, this could use some clarification. – Christian Paredes Jul 14 '10 at 4:25
  • Added clarification as per your inputs. :) – pugmarx Jul 14 '10 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.