Reputation: 3254
There are a few redirect rules for pages with query strings
RewriteCond %{QUERY_STRING} ^PAGEN_1=1 [NC]
RewriteRule ^news/$ http://www.mysite.ru/news/$ [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=1 [NC]
RewriteRule ^news/$ http://www.mysite.ru/news/$ [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=2 [NC]
RewriteRule ^news/$ http://www.mysite.ru/news/?PAGEN_1=2 [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=3 [NC]
RewriteRule ^news/$ http://www.mysite.ru/news/?PAGEN_1=3 [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=4 [NC]
RewriteRule ^news/$ http://www.mysite.ru/news/?PAGEN_1=4 [R=301,L]
RewriteCond %{QUERY_STRING} ^PAGEN_1=1 [NC]
RewriteRule ^articles/2/$ http://www.mysite.ru/articles/2/ [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=1 [NC]
RewriteRule ^articles/2/$ http://www.mysite.ru/articles/2/ [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=2 [NC]
RewriteRule ^articles/2/$ http://www.mysite.ru/articles/2/?PAGEN_1=2 [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=3 [NC]
RewriteRule ^articles/2/$ http://www.mysite.ru/articles/2/?PAGEN_1=3 [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=4 [NC]
RewriteRule ^articles/2/$ http://www.mysite.ru/articles/2/?PAGEN_1=4 [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=5 [NC]
RewriteRule ^articles/2/$ http://www.mysite.ru/articles/2/?PAGEN_1=5 [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=6 [NC]
RewriteRule ^articles/2/$ http://www.mysite.ru/articles/2/?PAGEN_1=6 [R=301,L]
Is there any way to write these rules in common, not for every query string?
UPD I used this code
RewriteCond %{QUERY_STRING} ^PAGEN_1=1 [NC]
RewriteRule ^news/$ http://www.mysite.ru/news/$ [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=1 [NC]
RewriteRule ^news/$ http://www.mysite.ru/news/$ [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=([0-9]*)$ [NC]
RewriteRule ^news/(.*)$ http://www.mysite.ru/news/?PAGEN_1=%1 [R=301,L]
RewriteCond %{QUERY_STRING} ^PAGEN_1=1 [NC]
RewriteRule ^articles/2/$ http://www.mysite.ru/articles/2/ [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=1 [NC]
RewriteRule ^articles/2/$ http://www.mysite.ru/articles/2/ [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=([0-9]*)$ [NC]
RewriteRule ^articles/2/(.*)$ http://www.mysite.ru/articles/2/?PAGEN_1=%1 [R=301,L]
but I'm not sure about it. It works but I think maybe it should be simpler.
Upvotes: 0
Views: 32
Reputation: 18671
You can use:
RewriteCond %{QUERY_STRING} (?:^|&)PAGEN_1=1(?:&|$) [NC]
RewriteRule ^news/?$ http://www.mysite.ru/news/? [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=(\d+)(?:&|$) [NC]
RewriteRule ^news/?$ http://www.mysite.ru/news/?PAGEN_1=%1 [R=301,L]
RewriteCond %{QUERY_STRING} (?:^|&)PAGEN_1=1(?:&|$) [NC]
RewriteRule ^articles/(\d+)/?$ http://www.mysite.ru/articles/$1/? [R=301,L]
RewriteCond %{QUERY_STRING} ^&PAGEN_1=(\d+)(?:&|$) [NC]
RewriteRule ^articles/(\d+)/?$ http://www.mysite.ru/articles/$1/?PAGEN_1=%1 [R=301,L]
Upvotes: 1