Yaron U.
Yaron U.

Reputation: 7891

mod_rewrite not passing querystring

I have an apache2 server installed with PHP CGI to run php scripts inside one of my directories I have .htaccess file with the following:

RewriteEngine On
RewriteRule ^article\/(\d+)\/?$ article.php?id=$1 [NC,QSA]

when entering URI such as http://www.mysite.com/article/132/ the rewrite makes the redirect but inside article.php I can't read $_GET["id"] (var_dump from $_GET/$_REQUEST results in empty array

in another server I have which has apache with mod_php - everything works fine.

I'm not 100% sure that the CGI is the reason for that - but I have a good reason for assuming so

Thanks!

Upvotes: 2

Views: 367

Answers (1)

Jon Lin
Jon Lin

Reputation: 143906

This sounds vaguely like mod_negotiation messing things up when you don't want it to. Try adding this to your htaccess file:

Options -Multiviews

The Multiviews options turns on something in mod_negotiation which tries to guess what resource a request is after. When it sees the URI /article/something and then it sees that there is a file /article.php, it assumes that you meant /article.php/something and serves that up outright, completely bypassing mod_rewrite.

Upvotes: 2

Related Questions