Access GET variables using PHP + .htaccess

I am developing a website using PHP. My .htaccess has this rewrite rule:

RewriteEngine On
RewriteRule ^book/([^/]*)\.html$ book.php?title=$1 [L]

So, the URL that looked like this: www.example.com/book.php?title=title-of-the-book turns into www.example.com/book/title-of-the-book.html

In a specific case, from another page on the site, I want to link to such pages: www.example.com/book.php?title=title-of-the-book?myfield=1 which then turns into www.example.com/ book / title-of-the-book.html? myfield = 1.html

Being one, I cannot use GET variables using the usual PHP method

$variable = $_GET['myfield']

How to solve this problem?

+3
source share
1 answer

[QSA] ( ), URL.

RewriteEngine On
RewriteRule ^book/([^/]*)\.html$ book.php?title=$1 [QSA,L]

PS: * ? +?

+7

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


All Articles