G
G
Good Samaritan2018-02-05 16:12:42
htaccess
Good Samaritan, 2018-02-05 16:12:42

How to correctly form a rule for mod_rewrite?

I have a rule for links like ru/catalog/windows/browser

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php/$1/$2/$3/$4

but it does not work for links like browser yandex , that is, when there is a space in the word.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stimulate, 2018-02-05
@djamali

([a-zA-Z0-9_- ]+)
или
([^\/]+)

V
Viktor Taran, 2018-02-05
@shambler81

God, what the hell did you write?
1. Read up on greedy and lazy quantifiers and you'll know Zen. And that will solve your problem.
2. you don't need to list everything except the slash, because there are OOOOO exceptions [^/]- this is NOT
www.exlab.net/files/tools/sheets/mod_rewrite/mod_r...
And so
1. Read about lazy quantifiers and put a limit on the third slash . (but this is already a bro level)
well, in your version, put .+it but not [^/], and naturally close it with a slash, in this case everything will be highlighted up to the first slash, and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question