How to force rewrite URL?

If the user clicks on these links or writes these links in the address bar, I would like to force a rewrite.

Is it possible?

index.php?page=admin--index before admin/index

...

index.php?page=team--create before team/create

thanks

+4
source share
1 answer

You can use:

RewriteCond %{THE_REQUEST} /index\.php\?page=([^\s&]+)--([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [L,R]

And if you need to go in another direction:

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?page=$1--$2 [L]
+2
source

Source: https://habr.com/ru/post/1620296/


All Articles