A
A
Albert Kazan2019-04-25 19:39:54
Regular Expressions
Albert Kazan, 2019-04-25 19:39:54

How to write such a regular expression under htaccess?

Hey!
Let's say there is such a link example.ru/mypanel/unit/orders/then/.../end/under a separate folder "mypanel".
htaccess should direct it to
/mypanel/index.php?page=&1&target=&2,
where $1 is "unit" from the example and $2 is everything after "unit" i.e. "orders/then/.../end"
I don't know if this is a simple expression or a complex one. Can anyone help?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-04-25
@dodo512

If .htaccess is in the root of the site.

RewriteEngine On
RewriteRule ^mypanel/([^/]+)/(.+)/$ /mypanel/index.php?page=$1&target=$2 [L]

If .htaccess is in the /mypanel/ folder.
RewriteEngine On
RewriteRule ^([^/]+)/(.+)/$ index.php?page=$1&target=$2 [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question