O
O
Optimus2015-12-07 18:42:29
PHP
Optimus, 2015-12-07 18:42:29

How to pass GET parameters with routing?

Use such htaccess for beautiful URLs like site.ru/wtfnigga

RewriteEngine On  
  
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  

RewriteRule ^(.*)$ ./index.php?route=$1

But if you pass some parameters like site.ru/wtfnigga?a=1&b=2&c=3, then he still sees only wtfnigga and get-parameters do not naturally reach the final php file. How to improve htaccess or index.php to reach?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Entelis, 2015-12-07
Pyan @marrk2

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

R
Ratami Sato, 2015-12-07
@reatachi_kun

For me, for beautiful URLs, it's better to use this #For
example, the user's page
RewriteRule ^u([0-9]+)(/?)+$ profile.php?id=profile&id=$1 [L]
And the user's address will look like this:
/u1 or /u2, depending on the user ID
profile.php?id=profile&id= naturally replace with your own

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question