Parsing get parameters in apache mod rewrite

apache-2.2mod-rewrite

I am using the PHP Fat-Free framework (http://fatfree.sourceforge.net/) to develop a website and I need to use GET Variables but they won't parse because I am using Mod Rewrite.

This is the current state of my .htaccess file:

# Enable rewrite engine and route requests to framework
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]

At the moment I can request a page with the framework by going www.domain.com/mypage but I need to use urls such as www.domain.com/mypage?variable=xyz

Is there anyway I can go about this? Thanks in advance!

EDIT:

I have used the Rewrite log with a level of 3 and requested www.domain.com/?x=1 and this is what was in the log:

::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2054260/initial] (3) [perdir D:/Development/xampplite/htdocs/] strip per-dir prefix: D:/Development/xampplite/htdocs/ -> 
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2054260/initial] (3) [perdir D:/Development/xampplite/htdocs/] applying pattern '.*' to uri ''
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2054260/initial] (1) [perdir D:/Development/xampplite/htdocs/] pass through D:/Development/xampplite/htdocs/
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#205a278/subreq] (3) [perdir D:/Development/xampplite/htdocs/] strip per-dir prefix: D:/Development/xampplite/htdocs/index.php -> index.php
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#205a278/subreq] (3) [perdir D:/Development/xampplite/htdocs/] applying pattern '.*' to uri 'index.php'
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#205a278/subreq] (1) [perdir D:/Development/xampplite/htdocs/] pass through D:/Development/xampplite/htdocs/index.php
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (3) [perdir D:/Development/xampplite/htdocs/] strip per-dir prefix: D:/Development/xampplite/htdocs/favicon.ico -> favicon.ico
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (3) [perdir D:/Development/xampplite/htdocs/] applying pattern '.*' to uri 'favicon.ico'
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (2) [perdir D:/Development/xampplite/htdocs/] rewrite 'favicon.ico' -> 'index.php'
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (3) [perdir D:/Development/xampplite/htdocs/] add per-dir prefix: index.php -> D:/Development/xampplite/htdocs/index.php
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (2) [perdir D:/Development/xampplite/htdocs/] trying to replace prefix D:/Development/xampplite/htdocs/ with /
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (1) [perdir D:/Development/xampplite/htdocs/] internal redirect with /index.php [INTERNAL REDIRECT]
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#3b68870/initial/redir#1] (3) [perdir D:/Development/xampplite/htdocs/] strip per-dir prefix: D:/Development/xampplite/htdocs/index.php -> index.php
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#3b68870/initial/redir#1] (3) [perdir D:/Development/xampplite/htdocs/] applying pattern '.*' to uri 'index.php'
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#3b68870/initial/redir#1] (1) [perdir D:/Development/xampplite/htdocs/] pass through D:/Development/xampplite/htdocs/index.php

Not sure if this would help?

Best Answer

That's not exactly how QSA works, please see here flags_qsa. I think you are needing to capture the new query string, you don't have an existing one.

Try something like this

# Enable rewrite engine and route requests to framework
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?$1 [L,QSA]

You may need to add a leading / to index.php?$1 depending on where the rewrite rules are located.

Related Topic