Reputation: 8183
I want to write my own router but I'm getting kinda stuck on my htaccess. The route stuff all works but I want to be able to parse GET variables into the url. I kinda want to be able to make this work: site.com/view/?p=1 or site.com/?p=1. My htaccess looks like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
So that's pretty much it. What should I do to be able to use GET variables?
Thanks!
Upvotes: 0
Views: 82
Reputation: 91742
If you want to pass an existing query string to your index.php
file, you need to add the QSA
flag:
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L,QSA]
Upvotes: 1