A
A
Albert Kazan2018-08-31 08:49:09
Regular Expressions
Albert Kazan, 2018-08-31 08:49:09

How to find the first match?

There are links like

../product/deny/?id=1
../product/?id=1

htaccess should only process the first match, i.e. in this example only "product" (and pass it as $1 to the p key). And if there are subsequent arguments in slashes, then pass them as $2, probably to another key.
This is how it works now
RewriteRule ^(?!.*mypanel|public)(.*?)/$ index.php?p=$1 [L,QSA]

Lord, how difficult these regular expressions are for me ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Smolin, 2018-09-06
@Farrien

I propose to write 2 instructions:
RewriteRule ^([^/]+)/?$ /index.php?p=$1 [L,QSA]
RewriteRule ^([^/]+)/(.+)/?$ /index. php?p=$1&p2=$2 [L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question