john doe john doe - 1 year ago 82
PHP Question

Mod rewrite put entire REQUEST_URI into GET request

I am trying to pass the entire Request_Uri into a $_GET request however the only things it's passing is 'test.php'

Htaccess code
RewriteEngine on
RewriteRule ^(.*)$ test.php?data=$1 [L]

echo $_GET['data'];

However the only thing it display is 'test.php' what am I doing wrong?

Answer Source

Use this:

RewriteEngine on

# skips files
RewriteCond %{REQUEST_FILENAME} !-f
# skips directories
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ test.php?data=$1 [L,QSA]

Without these 2 conditions your rules runs twice since you're matching .* and you get rewritten URI test.php as GET parameter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download