S
S
Sergey Konev2021-11-12 08:17:16
htaccess
Sergey Konev, 2021-11-12 08:17:16

How to convert GET request to CNC?

Good afternoon!

Due to get links, I can't use sharer.php from various social networks correctly.

I managed to convert this url https://my-web.com/index.php?page=news&id=22 to https://my-web.com/news?id=22 using .htaccess

RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^(.*)$ https://my-web.com/index.php?page=news&id=%1 [L]


But I need to transform in such a way that the url is like this:
https://my-web.com/news/id/22
please help me how to implement this using .htaccess if possible.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan, 2021-11-18
@kuchuluk

RewriteRule ^([a-z]+)/([a-z]+)/([0-9]+)/$ /?news=$1&id=$2&num=$3&%{QUERY_STRING} [NS,L]

news, id, num are abstract names, you can name them in your own way to catch them in the handler file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question