acewunderbar
acewunderbar

Reputation: 23

PHP/RewriteRule: GET variables don't get passed through

I have a .htaccess file that routes all traffic through a frontloading index.php file using

Options +FollowSymLinks
RewriteEngine On
RewriteRule (.*) index.php?$1 [PT]

But the $_GET varaibles don't get passed for some reason..

In the index.php when I var_dump the $_GET, all I get is

array(1) { ["index_php"]=> string(0) "" }

no matter what is in the query string.

What do I need to change?

Thanks!

Upvotes: 2

Views: 1010

Answers (4)

Michael Irigoyen
Michael Irigoyen

Reputation: 22957

You need to use the query string append flag at the end of your rewrite rule. Place [QSA] at the end of the rewrite rule you would like to retain any $_GET variables. Remember, that if you'd like to use the [L] flag as well, you would write [QSA,L].

mod_rewrite - Apache

Upvotes: 1

Ben
Ben

Reputation: 62484

Try this:

index.php?page=$1

You have to define a parameter for that value. If you want all query string values you can add {QUERY_STRING} after $1

Upvotes: 1

Robik
Robik

Reputation: 6127

I think you are doing it wrong. Of you want get www.adress.com/page/5/comments create rule like it.

Upvotes: 0

powtac
powtac

Reputation: 41080

Try this

RewriteRule .* index.php [L] 

Upvotes: 0

Related Questions