Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The 301 is redirecting but it is appending the old url onto the end of the new url, like so:

http://www.example.co.uk/new-dir/new-page/?/old-dir/old-page/

This is my .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.co.uk [NC]
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [R=301,L]
Redirect 301 /old-dir/old-page/ http://www.example.co.uk/new-dir/new-page/
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L]
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Don't use mod_alias for your redirect; they're not operating in the order that you're expecting based on the order you've put them in in the file. The query string added to the redirect location is coming from that last RewriteRule.

Replace your Redirect line:

RewriteRule ^old-dir/old-page/?$ http://www.example.co.uk/new-dir/new-page/ [R=301,L]

This is assuming your htaccess context is the document root.

share|improve this answer
    
Perfect! Thank you. –  showFocus Feb 19 '12 at 22:03

Your Answer

 
discard

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.