Home > Backend Development > PHP Tutorial > PHP program of zf2 framework, the test environment uses apache, and the quasi-production environment uses nginx, problems arise

PHP program of zf2 framework, the test environment uses apache, and the quasi-production environment uses nginx, problems arise

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 08:55:59
Original
1174 people have browsed it

使用zf2框架开发的PHP程序

开发在路由的结尾增加了/以解决404的问题

在测试环境(使用apache)是正常的

而在准生产环境(使用nginx)不正常

路由去掉/也可以访问,但增加/后在nginx环境下会自动跳转到路由的首页,而开发的代码部分连接已经带了/,只能想办法删除结尾的/

使用关键词 “nginx  结尾斜杠”在google搜索到的解决办法解决不了这个问题

改用关键词“nginx  slash end”在google搜索看到类似How to remove trailing slash from URL using Nginx文章

解决办法:修改这个项目的nginx的vhost配置文件

增加一行

rewrite ^/(.*)/$ /$1 permanent;

类似这样:

<span>server {
listen  :80;
server_name  www.site.com;
rewrite ^/(.*)/$ /$1 permanent;
}</span>
Copy after login

service nginx reload

以上就介绍了zf2框架的PHP程序,测试环境使用apache,准生产环境使用nginx,出现的问题,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
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
Latest Issues
Error restarting nginx
From 1970-01-01 08:00:00
0
0
0
server - Nginx configuration webapp problem
From 1970-01-01 08:00:00
0
0
0
Nginx default.conf problem
From 1970-01-01 08:00:00
0
0
0
centos7 - NGINX exception occurs
From 1970-01-01 08:00:00
0
0
0
nginx load balancing
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template