A
A
akvazoo2018-04-17 11:34:53
htaccess
akvazoo, 2018-04-17 11:34:53

How to make a mass 301 redirect when changing the get/post variable name in the url?

How to make a mass 301 redirect when changing the name of the get/post variable in the url from the old to the new one. For example: addresses /page.php?id=x to /page.php?fid=x

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2018-04-17
@shambler81

# 301 --- http://site.ru/page.php?id=x => http://site.ru/page.php?fid=x
RewriteCond %{QUERY_STRING} (^|&)id\=(.+)($|&)
RewriteRule ^page\.php$ /page.php?fid=x [L,R=301]

Get is not part of the url and is cut out differently %2 - this is an analogue of $2 but from RewriteCond and this is the second bracket in it (.+)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question