Home > Backend Development > PHP Tutorial > Nginx Rewrite 配置

Nginx Rewrite 配置

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:51:25
Original
1000 people have browsed it

这个是我现有的配置.

	location / {
		index index.php;
	}
	
	location /request/ {
		rewrite ^/request/(.+)$ /request?model=$1 break;
	}
	
	location ~ \.php {
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		include fastcgi_params;
		fastcgi_param REQUEST_METHOD $request_method;
	}
Copy after login
Copy after login

我现在要实现的是,当访问: /request/concact 路径时,rewrite 到/request/?model=contact

然后不丢失POST 参数并且浏览器不跳转。

现在这个配置给我的麻烦是,请求从POST rewrite成了GET, 并且地址做了跳转。

回复内容:

这个是我现有的配置.

	location / {
		index index.php;
	}
	
	location /request/ {
		rewrite ^/request/(.+)$ /request?model=$1 break;
	}
	
	location ~ \.php {
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		include fastcgi_params;
		fastcgi_param REQUEST_METHOD $request_method;
	}
Copy after login
Copy after login

我现在要实现的是,当访问: /request/concact 路径时,rewrite 到/request/?model=contact

然后不丢失POST 参数并且浏览器不跳转。

现在这个配置给我的麻烦是,请求从POST rewrite成了GET, 并且地址做了跳转。

rewrite ^/request/(.+)$ /request?model=$1 break;

这句第二个request后面加一个斜杠就好了:

rewrite ^/request/(.+)$ /request/?model=$1 break;
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
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