0

I am currently wanting to enable $_GET parameters in my framework.

My current htaccess-file is like this, BUT it doesn't pass the ?param=param :(

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /{2,}([^\?\ ]*)
RewriteRule ^ /%1 [L,R=301,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^.*$ index.php?url=$0 [NC,L]

</IfModule>

When I try to go to this URL:

http://www.domain.com/test?test=test

All that gets passed is "test"

How can I make it possible to also pass $_GET-parameters?

denlau
  • 916
  • 2
  • 9
  • 21
  • Are you using a framework?, they have urlrewriting implemented via config files ... – ka_lin Oct 28 '13 at 23:51
  • This is a framework, I have developed myself, but the problem is, that I haven't had to use this before, but now I have :) – denlau Oct 28 '13 at 23:52
  • 1
    Nice,have you checked out this answer http://stackoverflow.com/questions/16388959/url-rewriting-with-php ? – ka_lin Oct 28 '13 at 23:54
  • 1
    also, you minght find [this](http://stackoverflow.com/a/19309893/727208) relevant. – tereško Oct 29 '13 at 00:03

1 Answers1

2

You need to add QSA to your RewriteRule:

RewriteRule ^.*$ index.php?url=$0 [NC,L,QSA]

QSA stand for Query String Attach

Sébastien
  • 11,860
  • 11
  • 58
  • 78
  • Okay, this works - it is weird I didn't figure that out. Is there any way to disallow the "url" as a parameter in the URL? Because if it is possible to write e.g.: http://domain.com/test?test=test&url=something then it will return "something" to the framework routing, and that shouldn't be allowed. Any fixes to that? :) – denlau Oct 28 '13 at 23:59
  • Indeed. However given that it's part of the URL anyone could pass anything anyway, so I guess you have to do the sanitization server/framework side. You should read all the links posted in the comments ;) – Sébastien Oct 29 '13 at 00:07