+ -
当前位置:首页 → 问答吧 → nginx rewrite问题

nginx rewrite问题

时间:2010-10-12

来源:互联网

大家好. 今天我将apache下的一个rewrite转换成nginx的rewrite的时候遇到一些比较奇怪的问题.

Apache:   RewriteRule ^/([0-9]+)/?$ /ps_index.php?pserid=$1 这个rewrite没问题,可以正常跳转.但是转换成nginx的时候......
Nginx:  rewrite ^/([0-9]+)/?$ /ps_index.php?pserid=$1 last;  就遇到无法跳转的问题.
在IE上敲  www.abc.com/ps_index.php?pserid=1  的时候直接就跳转成.www.abc.com/ps_index.php/   我就觉得很奇怪.在apache下访问www.abc.com/ps_index.php?pserid=1就没问题直接显示结果, 这个rewrite按道理应该跳转成www.abc.com/123/ 类似这样的页面才对.而直接输入www.abc.com/ps_index.php?pserid=1也应该直接显示出结果而不跳转才对.请大家帮帮忙.谢谢.

作者: zhangheng520   发布时间: 2010-10-12

这个设置到查询字符串,看看nginx对查询字符串有没有做特殊处理!

作者: todayhero   发布时间: 2010-10-12

但是很奇怪,另外一个类似的rewrite就正常.
rewrite ^/m([0-9]+)/?$ /m_index.php?mid=$1 last
结果输出正常.

作者: zhangheng520   发布时间: 2010-10-12

问题解决了, 是PHP程序里面写了301跳转,会自动加/ 导致的.

作者: zhangheng520   发布时间: 2010-10-12