mod_rewrite not passing querystring

ぐ巨炮叔叔 提交于 2019-12-13 16:58:11

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/19715478/mod-rewrite-not-passing-querystring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!