Help with GET

Okay so I’m creating my own framework script, the URL’s are gonna be:
controller.php?folder=foldernamehere&page=pagenamehere

So in the controller.php I have…


$folder = $_GET['folder'];
$page = $_GET['page'];
include('plugins/'.$folder.'/'.$page.'.php');

Then in .htaccess I will do:
Rewrite On
RewriteRule ^(.)/(.)\.php$ controller.php?folder=$1&page=$2

Well, works out fine if I access say… /users/index.php it will display the info perfect! But, on to my issue.
Well, say on that /users/index.php file, I want to get something from the URL… say, /users/index.php?user=bla
Well, it will not work for some reason! Any idea why? I believe its because I already have used it in the .htaccess file, but not sure… How can I fix it? Thanks a lot!

jw,

You’re KILLING the existing query string by creating a new one. Simply add the Query String Append flag [QSA] to your RewriteRule.

While you’re at it, though, PLEASE learn some regex as (.*) is the most dangerous thing that you can use (it’s a garbage collector AND it allows hackers “free access” to your include statement). At least you’re not accessing a database with the values submitted so that’s something in your favor. I hope you’re validating $folder and $page in controller because you’re definitely not in mod_rewrite! A place to start, if you have no other, is the mod_rewrite tutorial linked in my signature - it’s helped MANY members.

Regards,

DK