A
A
Alexey selftrips.ru2017-10-19 08:16:00
Regular Expressions
Alexey selftrips.ru, 2017-10-19 08:16:00

How to make a regular expression for redirect?

now urls are built according to the pattern
/category1/number(numbers only)/post
How to redirect from a url with a number to a url without a number? The problem is that categories can be with subcategories
i.e. there are addresses of the form
/ka1/number/post -> /ka1/post
and there are
/ka1/cat2/number/post -> /ka1/cat2/post
and so on

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Yanyshev, 2017-10-19
@selftrips

RewriteRule ^\/([\w\d]+)\/([\w\d]+)\/([\w\d]+)$ /$1/$3
RewriteRule ^\/([\w\d]+)\/([\w\d]+)\/([\w\d]+)\/([\w\d]+)$ /$1/$2/$4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question