A
A
Asen1232020-06-27 19:58:20
Apache HTTP Server
Asen123, 2020-06-27 19:58:20

How to remove GET from URL?

Good evening, I understand that the topic is not new, but still I can not find an answer. Here is the complete htaccess code:
"php_value upload_max_filesize 30M
php_value post_max_size 30M

php_value session.gc_maxlifetime 8640000
php_value session.cookie_lifetime 8640000
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule) php$. ?q=$1 [L,QSA]
RewriteEngine On
RewriteRule ^5$ $1 [L,QSA]
RewriteCond %{HTTP_HOST} ^site.ru$ [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
php_value default_charset utf-8
AddType 'text/html; charset=utf-8' .html .htm .shtml"

It is necessary that when I go to: site.ru/q?example=1 it should be site.ru/q/example/1.
I will be glad to help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2020-06-29
@Asen123

RewriteCond %{QUERY_STRING} (^|&)(.+)\=([0-9]{1,})($|&)
RewriteRule ^q$ /%2/%3? [L,R=301]

where (^|&)....($|&) - not an important thing
(.+)- any more than 1 letter or number - any numbers but not less than 1. - what was in the url before GET - the second group from RewriteCond - analogue of $2 from RewriteRule - remove get parameters.
([0-9]{1,})
^q$
%2
?

D
dodo512, 2020-06-27
@dodo512

site.ru/q?example=1 was site.ru/q/example/1

RewriteCond %{QUERY_STRING} (?:^|&)(example)=(1)(?:$|&)
RewriteRule ^q$ https://site.ru/q/%1/%2? [R=301,L]

Put at the beginning of the file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question