A
A
Andrey Denisov2016-05-16 15:37:42
PHP
Andrey Denisov, 2016-05-16 15:37:42

What regex to use for mod_rewrite?

I don’t understand regular expressions well, help me solve the problem
There is a URL: http:// /guest/s//?param1=item¶m2=123
where a random combination of letters like "uiohv" will randomly change in the future
When requesting this URL, it must be requested resource index.php located in the root
Now in mod_rewrite, there is a regular expression
writeRule ^guest/s/([a-zA-Z0-9_-]+)/$ index.php
Everything works only for index .php, except for uploaded files like css, js, jpg etc.
how to replace all requests with a URI like http:// IP /guest/s/vsdvds/ to http:// IP / site root, no matter what resources are requested?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Novikov, 2016-05-17
@BOOMER_74

RewriteRule ^guest/s/.* index.php
Any request starting with guest/s/ is redirected to index.php . By writing [a-zA-Z0-9_-]+ you have limited the choice to only lat. letters, numbers, _ and -, which is why requests like guest/s/file.css did not pass (there is no dot in the reg. expression).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question