A
A
Alexey selftrips.ru2018-04-17 17:33:45
Apache HTTP Server
Alexey selftrips.ru, 2018-04-17 17:33:45

How to correctly compose a regular expression for a redirect?

The URL contains (can start, end or stand in the middle) 5dddd where each d is a digit from 0 to 9
How to write a rule so that such a URL is redirected to a URL like site.ru/?p=5dddd

Answer the question

In order to leave comments, you need to log in

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

.*([0-9]{5}).* from zero to nine 5 times any snala and any from the end, in brackets what will be in $1
site.ru/\?p=$1 - substitute what is in brackets

RewriteRule ^.*([0-9]{5}).*$ http://site.ru/\?p=$1 [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question