So I redirect my old website to a new one using this redirect rule which I found here.

RewriteRule ^/(.*)$ http://www.newsite.com/ [L,R]

The problem is when users enter a page on the old site like www.oldsite.com/something.html it jumps to www.newsite.com/something.html. What I need is that all pages no matter what, redirect to http://www.newsite.com/. Any ideas on how I can do this?

link|improve this question
feedback

3 Answers

RewriteRule ^/(.*)$ http://www.newsite.com/ [L,R]

is what you want. The effect you're describing is

RewriteRule ^/(.*)$ http://www.newsite.com/$1 [L,R]

which is not the same thing. If you're editing the configuration through some editor or website, it might be "interpreting" what it thinks you want instead of what you have entered.

link|improve this answer
I just tried this and it doesn't work for me. (The query string continues to be passed.) – Luke Nov 8 '10 at 2:01
I just double checked it on Apache 2.2, works. What are you running? – Chris S Nov 8 '10 at 2:03
feedback
RewriteRule ^/.*$ http://www.newsite.com/? [L,R]

The "?" will kill any other query string.

link|improve this answer
I'd suggest "R=301" for SEO, but this is the correct solution. – BMDan Nov 8 '10 at 2:12
It work fine on index page, but on other pages shows me a google message Oops! This link appears to be broken. error on Chrome. – Jon Doe Nov 8 '10 at 3:13
feedback

Umm off the top of my head try something like this..

Edit the vhost and use

Redirect permanent / http://www.newsite.com/

whereby your just redirecting the whole "oldsite" to the "newsite"

The idea is just redirect the base of oldsite.com to newsite.com before anything else right??

This might also work

RewriteRule ^/$ http://www.newsite.com [R=permanent,L] 
link|improve this answer
+1 for the permanent (good idea) but -1 because your example doesn't kill the query string or redirect everything under the old domain like he requested. – Luke Nov 8 '10 at 2:02
feedback

Your Answer

 
or
required, but never shown

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