O
O
OwlCloud2019-08-05 22:28:51
htaccess
OwlCloud, 2019-08-05 22:28:51

Pretty URL problem, how to fix?

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?action=$1 [QSA,L]

On my site, everything is implemented through index.php with a beautiful view of the site.ru/cabinet type, which replaces site.ru/index.php?action=cabinet
But I ran into such a problem as the need for a site.ru/index link. php?action=cabinet&userId=4
How to turn it into site.ru/userId/4 ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2019-08-06
@OwlCloud

RewriteCond %{QUERY_STRING} (^|&)action\=cabinet($|&)
RewriteCond %{QUERY_STRING} (^|&)userId\=4($|&)
RewriteRule ^index\.php$ /userId/4? [L,R=301]

S
Siverius, 2019-08-05
@Siverius

RewriteRule ^(.*)$ index.php?$1 [QSA,L]
And inside, parse the incoming parameters, the first will always be an action, the second - some value

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question