Reputation: 98
Im trying to redirect old Google cached links to our new site. So it works in my regexp editor but not in my htacess file?
The first rule seems to work but the second does not. I've left examples above the rules.
# Legacy site redirects
# For homes home and search:
# www.site.ie/results_lost_found.html?search_type=lost_found&ad_type=&location_id=&x=31&y=12
RewriteRule ^results_lost_found|results_home(.+)search_type=lost_found(.*)$ lost_found [NC,R=301,L]
# www.site.ie/results_home.html?search_type=for_home&pet_type_id=&location_id=&x=14&y=10
RewriteRule ^results_lost_found|results_home(.*)search_type=for_home(.*)$ for_homes [NC,R=301,L]
Upvotes: 1
Views: 34
Reputation: 784938
None of your rules would work because RewriteRule only matches URI without query string. In mod_rewrite you would do something like this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^search_type=lost_found&ad_type=&location_id=&x=31&y=12$ [NC]
RewriteRule ^(results_lost_found|results_home)\.html$ /lost_found? [NC,R=301,L]
Note use of query string variable %{QUERY_STRING}
to match your query string.
Upvotes: 1