Forum Moderators: phranque
The old URLs look like:
real-estate?view=property&id=405
And I need to 301 them to:
real-estate?view=properties&id=405
Obviously there are hundreds of property IDs and I would like if they forwarded to the new "correct" version of the URL. I contacted the developer and he told me to do this:
RedirectMatch 301 ^/real-estate?view=property&id=(.*)$ [yoursite.com...]
However that doesn't work at all. I've tried fiddling with other options, but I'm afraid I'm too much of a noob to figure this one out. Any help would be greatly appreciated!
You'll need to use mod_rewrite. If you currently have no working mod_rewrite code, you'll need either all of these lines or only the last three -- I can't tell, and you'll have test to find out.
If you do currently have other working mod_rewrite rules, you'll need only the last two, and this new rule should be placed before any more-general external redirect rules (e.g. domain canonicalization), and before all internal rewrite rules:
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{QUERY_STRING} ^view=property&id=(.+)$
RewriteRule ^real-estate$ http://www.example.com/real-estate?view=properties&id=%1 [R=301,L]
Jim