Answer the question
In order to leave comments, you need to log in
How to write a 301 dynamic redirect in Apache?
site.ru/?page=3 to site.ru/page/3/ (any number can be)
How to write a 301 dynamic redirect on Apache?
Answer the question
In order to leave comments, you need to log in
RewriteCond %{QUERY_STRING} (?:^|&)page=(\d+)
RewriteRule ^(.*)$ /$1page/%1/? [R=301,L]
RewriteCond %{QUERY_STRING} (?:^|&)page\=(.+)(?:$|&)
RewriteRule ^cat/$ /cat/page/%1/? [L,R=301]
(?:^|&)
- this or ?
or &
a ?:
excludes this group, that is, it does not become $1 (.+)
- the first group is 1 character or more %1
- the equivalent of $1 but already from RewriteCond
- /?
remove get parameters Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question