T
T
Toryka2020-04-21 11:02:02
htaccess
Toryka, 2020-04-21 11:02:02

The page does not redirect to a new one. How to solve?

I am transferring the site from the subcategory to public_html. From the old site there are links of this type site.ru/catalog.php?id=1
, it is necessary that they look like this site.ru/id=1.
I tried this
RewriteRule ^catalog.php$ site.ru/id=1 [L,R=301]
As a result I got the following link /id=1?_route_=catalog.php
Redirect 301 https://site.ru/catalog.php ?id=1 site.ru/id=1 - no results.
Please tell me how to solve

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2020-04-21
@dodo512

RewriteCond %{QUERY_STRING} (?:^|&)(id=\d+)
RewriteRule ^catalog\.php$ http://site.ru/%1? [L,R=301]

Append to the beginning of the file above the rest of the rules.

V
Viktor Taran, 2020-04-22
@shambler81

RewriteCond %{QUERY_STRING} (^|&)id\=(d+)($|&)
RewriteRule ^catalog\.php$ /id=%2? [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question