P
P
Pavel2020-05-26 22:14:21
htaccess
Pavel, 2020-05-26 22:14:21

How to make a redirect in .htaccess to a partially different url?

Help me write an expression for redirecting pages of the form:

http://site.ru/text-01-mart-2020

to url with a different date and month:

http://site.ru/text-02-aprel-2020

Where text is any text in Latin.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-05-28
@shambler81

RewriteRule ^(.+)\-01\-mart\-2020$ /$1\-02\-aprel\-2020? [L,R=301]

.+- 1 or more characters
(..)- just brackets collect everything in the variable $1 if there were second brackets, then they would be $2,
we substitute all this into "where"
and ?in the end it will remove all get parameters if they were there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question