V
V
virshich2019-12-25 14:14:23
htaccess
virshich, 2019-12-25 14:14:23

How to set up a 301 redirect via .htaccess from an old domain with GET parameters to a new domain without parameters?

There are two sites www.oldsite.ru and https://newsite.ru
You need to:
1. Redirect the page www.oldsite.ru/pages/page_0.aspx?id_page=272&id_re... to https://newsite.ru/b .html
2. Redirect the page www.oldsite.ru/pages/page_0.aspx?id_page=888&id_re... to https://newsite.ru/ccc.html
3. And ALL other pages from the old site to the main page of the new https: //newsite.ru
I came up with this option myself. Is the approach correct?

RewriteEngine On
RewriteCond %{QUERY_STRING} ^id_page=272&id_region=1
RewriteRule ^pages/page_0.aspx$ b.html? [R=301,L]
RewriteCond %{QUERY_STRING} ^id_page=888&id_region=34
RewriteRule ^pages/page_0.aspx$ ccc.html? [R=301,L]
RewriteCond %{REQUEST_URI} (.*)
RewriteRule ^(.*)$ https://newsite.ru? [L,R=301]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-12-25
@virshich

RewriteEngine On

RewriteCond %{THE_REQUEST} " /pages/page_0\.aspx\?id_page=272&id_region=1 "
RewriteRule ^ https://newsite.ru/b.html? [L,R=301]

RewriteCond %{THE_REQUEST} " /pages/page_0\.aspx\?id_page=888&id_region=34 "
RewriteRule ^ https://newsite.ru/ccc.html? [L,R=301]

RewriteRule ^ https://newsite.ru/ [L,R=301]

Or
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|&)id_page=272($|&)
RewriteCond %{QUERY_STRING} (^|&)id_region=1($|&)
RewriteRule ^pages/page_0\.aspx$ https://newsite.ru/b.html? [L,R=301]

RewriteCond %{QUERY_STRING} (^|&)id_page=888($|&)
RewriteCond %{QUERY_STRING} (^|&)id_region=34($|&)
RewriteRule ^pages/page_0\.aspx$ https://newsite.ru/ccc.html? [L,R=301]

RewriteRule ^ https://newsite.ru/ [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question