Problem with form (GET method) and URL Friendly

Asked

Viewed 592 times

2

I have a problem sending a form, because I am using a scheme that changes the pages according to the GET['page'], and I used the user-friendly url to take out all that code to leave only the page name, for example localhost?page=inicio, now is localhost/inicio.

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

Example of how it’s happening: localhost/inicio?b=pedro, that means localhost?page=inicio?b=pedro

How to make it look like this localhost/inicio&b=pedro, that 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
  • Did you make the URL friendly with HTACCESS right? Can you post its code? Use the link edit just below your question to add this information.

  • Ready ^^ !!!

  • Romario, are you willing to change the rule of your form with jQuery/Javascript? Take a look at this answer: http://answall.com/a/75970/8493 if it is, post your form code (and javascript codes already used if any).

1 answer

1


Just add to flag [QSA] (Querystring Append):

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

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

Source

It can also simplify the first two rules to just one:

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

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

  • It worked out dude you’re great at! where do you have material so I can be studying about these items? What is QSA? what does it do?

  • I put there below the code the link fountain @Romariopires

Browser other questions tagged

You are not signed in. Login or sign up in order to post.