K
K
khomaldi2019-07-22 18:04:10
htaccess
khomaldi, 2019-07-22 18:04:10

How to change url with GET parameters in .htaccess?

Hello.
There is urla kind https://site.ru/profile?username=georgii.
How to get from this https://site.ru/profile/georgii?
And how can (I think that this is already done not through redirects) https://site.ru/profile?username=georgiibe replaced with https://site.ru/georgii?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2019-07-22
@khomaldi

Specifically for TK

RewriteCond %{QUERY_STRING} (^|&)username\=georgii($|&)
RewriteRule ^profile$ /profile/georgii? [L,R=301]

And here I wang that you need not only 1 get parameter, but any of them
RewriteCond %{QUERY_STRING} (^|&)username\=(.+)($|&)
RewriteRule ^profile$ /profile/%2? [L,R=301]

And Yes, it is done in the normal way through the CNC
Like this
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
</IfModule>

And then it processes php in 99% of the CMS, this has already been implemented.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question