Forum Moderators: phranque
I just modified my site and there are this of url's no more available;
profile.php?change_css=modern
or
news.php?offset=1&change_css=modern
The pages are still there but the "change_css" no more.
Several url's like above are indexed with google and other search engines adn I want to remove them there.
I tried a lot of things and think that this kind of rule have to be used:
RewriteEngine on
RewriteCond %{QUERY_STRING} change_css=([a-z]{4,6})
RewriteRule ^(.*)\.php$ http://www.example.com/$1.php [R=permanent,L]
This is wrong because it ends in a endless loop.
How can just remove the change_css from the url?
regards Olaf
[edited by: jdMorgan at 9:30 pm (utc) on Nov. 27, 2005]
[edit reason] example.com [/edit]
It's quite tricky, and you may have to use two rules:
# Case 1: Additional parameters follow change_css
RewriteCond %{QUERY_STRING} ^(.+&)?change_css=[a-z]{4,6}&(.+)?$ [NC]
RewriteRule ^(^.)+\.php$ http://www.example.com/$1?%1%2 [R=301,L]
#
# Case 2: No more parameters follow change_css
RewriteCond %{QUERY_STRING} ^((.+)&)?change_css=[a-z]{4,6}$ [NC]
RewriteRule ^(^.)+\.php$ http://www.example.com/$1?%2 [R=301,L]
are you sure that in this case the part of the querystring (change_css) is removed?
You told me in another thread that the http status is very important for google. I want to remove the entries from the index with this querystring. What if I send a header (410) in every page for every request with this querystring and then stop the script?
you know what I mean? or what is the best way to handle this?
regards Olaf
Options +FollowSymLinks
RewriteEngine on
#
# Case 1: Additional parameters follow change_css
RewriteCond %{QUERY_STRING} ^(.+&)?change_css=[a-z]{4,6}&(.+)?$ [NC]
RewriteRule ^([^.]+\.php)$ http://www.example.com/$1?%1%2 [R=301,L]
#
# Case 2: No more parameters follow change_css
RewriteCond %{QUERY_STRING} ^((.+)&)?change_css=[a-z]{4,6}$ [NC]
RewriteRule ^([^.]+\.php)$ http://www.example.com/$1?%2 [R=301,L]