ignore query string

New to mod_rewrite? This is a good place to start.

ignore query string

Postby tomoioaga » Thu Jun 18, 2009 2:30 am

hi,
thank you for your help.
I know have a simple problem, but in all my tests didn't work, so I thought I should let the experts have an opinion :)
so I need all URL's of this format

www.site.com/ip-XXXX.html?id_cfm=XXXX (XX being digits)
301 redirected to www.site.com/ip-XXXX.html
(they are now seen as duplicates by google, but they are not)

RewriteRule ^/ip-(.*)\.html?id_cfm=(.*)$ /ip-$1.html [R=301,L]
is simply ignored... :(
tomoioaga
 
Posts: 4
Joined: Mon Feb 02, 2009 3:13 am

Postby richardk » Thu Jun 18, 2009 11:36 am

Query strings are matched with the %{QUERY_STRING} variable and RewriteConds.

/ip-XXXX.html?id_cfm=XXXX (XX being digits)
301 redirected to /ip-XXXX.html

Do you want to remove every query sting from those URLs or just the id_cfm variable? Are there any query string variables that need to be kept?

Try
Code: Select all
Options +FollowSymLinks

RewriteCond %{QUERY_STRING} ^(.*&)?id_cfm=[0-9]+(&.*)?$ [NC]
RewriteRule ^ip-[0-9]+\.html$ /$0? [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 113 guests

cron