Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

RewriteRule ^/(.*)$ [L,R]

The problem is when users enter a page on the old site like it jumps to What I need is that all pages no matter what, redirect to Any ideas on how I can do this?

share|improve this question
RewriteRule ^/(.*)$ [L,R]

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

RewriteRule ^/(.*)$$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.

share|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
RewriteRule ^/.*$ [L,R]

The "?" will kill any other query string.

share|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

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

Edit the vhost and use

Redirect permanent /

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

The idea is just redirect the base of to before anything else right??

This might also work

RewriteRule ^/$ [R=permanent,L] 
share|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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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