Form problem (GET method) and Friendly URL

2

I'm having a problem sending a form, as I'm using a schema that changes the pages as GET['page'] , and I used the friendly url to take all that code to leave only the name of the page, for example localhost?page=inicio , is now localhost/inicio .

But I have a problem with this because when I need to send another get , php can not get it, because the form sends the " ? " in front of the get, and php will only catch if the html send " & " before the GET name

Example of how it is happening: localhost/inicio?b=pedro , this means localhost?page=inicio?b=pedro

How do I stay like this localhost/inicio&b=pedro , which will look like this without the friendly url localhost?page=inicio&b=pedro .

RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]*)$ index.php?page=$1
RewriteRule ^([^/]*)/$ index.php?page=$1


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
    
asked by anonymous 30.07.2015 / 20:56

1 answer

1

Just add the flag [QSA] ( QueryString Append ):

RewriteRule ^([^/]*)$ index.php?page=$1 [QSA]
RewriteRule ^([^/]*)/$ index.php?page=$1 [QSA]

RewriteRule ^(.*)$ $1.php [QSA]

Font

You can also simplify the first two rules for just one:

RewriteRule ^([^/]*)/?$ index.php?page=$1 [QSA]

The ? after a character in the regular expression means that it is optional, it may or may not have it.

    
30.07.2015 / 22:36