Home > Backend Development > PHP Tutorial > Nginx伪静态写法问题

Nginx伪静态写法问题

WBOY
Release: 2016-06-23 13:41:35
Original
924 people have browsed it

目标:将 zonggang.php?shuhao=130重写成  read/130
以前用的win服务器,使用appserv ,这样写就ok:
RewriteRule ^/?read/([0-9]+) zonggang.php?shuhao=$1

现在换了liunx ,用的nginx服务器在网上找了转化写法

 rewrite ^/?read/([0-9]+)$zonggang.php?shuhao=$1 last ;

结果提示404错误,请教大家,我的写法是不是有问题


回复讨论(解决方案)

重写成  read/130 就需要启用 path_info 模式,你做到了没有?

重写成  read/130 就需要启用 path_info 模式,你做到了没有?


path_info 模式已经开启

建一文件
show.php
echo $_SERVER['PATH_INFO'];

执行
http://servername/show.php/a/b/c/d

用这个方法,已经得到结果 /a/b/c/d

rewrite ^/?read/([0-9]+)$ zonggang.php?shuhao=$1 last ;

rewrite ^/?read/([0-9]+)$ zonggang.php?shuhao=$1 last ;


还是404,真是奇了怪了

已经搞定,还是静态规则写错了,找了个转换工具
rewrite ^/?read/([0-9]+) /zonggang.php?shuhao=$1;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template