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

I have two websites, an old one and a new one. I have set up redirects in the old site to point to pages on the new site. However, I'm seeing some strange behavior on some of the redirects.

E.g. I have the following redirect in the .htaccess on the old site:

<IfModule mod_rewrite.c>
    RewriteEngine On

    Redirect 301 /car-finance/car-loan-comparison

When I go to the old site to /car-finance/car-loan-comparison I'm being redirect to the new site on the path /car-finance/car-loan-comparison resulting in a 404.

For some reason the old path is applied to the domain in the redirect instead of the redirected path.

This is what I have in the .htaccess of my newsite:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^newsite\.com$ [NC]
    RewriteRule ^(.*)$$1 [L,R=301]

Any ideas much appreciated,

share|improve this question
On the new site, you have a rewrite rule to go from to That's because and DNS record point to the same server and you want to keep it pretty with the www? The old site then is a totally different domain? – ETL Apr 21 '13 at 22:43
Do you have any generic redirects for the old site to the new site? – becomingwisest Apr 21 '13 at 23:40
@ETL; From oldsite I'm always redirecting to the www version of newsite. I assume this means that the www redirect on newsite never gets triggered. – Luke Apr 22 '13 at 0:39
@becomingwisest; The last redirect on oldsite is a redirect of / to if that is what you mean with a 'generic' redirect. When I take it out it doesn't make a difference. – Luke Apr 22 '13 at 0:40
BTW: Redirect does not need mod_rewrite (it's part of mod_alias), so you don't need to put it in an "ifModule mod_rewrite" block. – Krist van Besien Apr 22 '13 at 5:07
up vote 1 down vote accepted

Use the rewrite logging option to get some detailed output of what it is doing; you'll be able to see where the problem is, and mostly likely exactly why it is happening:

Add these to your rewrite config:

RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 9

Don't forget to disable it afterwards or you'll chew up your disk space and reduce performance.

share|improve this answer

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.