I've got a site with many incoming links to the old structure (gone for years), with tonnes of URL vars that are no longer relevant, as the database mappings were changed. So, I'd like to redirect:




without the query string at the end. The actual query string varies - there are hundreds of them, but since they don't match up to a particular case anymore, I want to take people to the new index page for the content they're looking for, so they can find it from there.

I currently use:

RedirectMatch 301 ^/oldfile\.aspx$ /newfile.php

This puts the query back on the end though. Can someone let me know the voodoo recipe I need?


RewriteEngine on

RewriteRule ^oldfile.aspx*$ /newfile.php? [R]

This will in the end lead to showin newfile.php in url , if you want users to see oldfile.aspx and really hit newfile.php put [L] instead of [R] flag in mod_rewrite rule.

Add the question mark after newfile.php? so old string after ? gets lost.

  • Perfect, thanks. I'd actually tried this after reading a similar thread over on stackoverflow, but I had put a leading / in the regex section. Removed that, and we're away! – Dan Feb 17 '11 at 15:15

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.