Home > Backend Development > PHP Tutorial > nginx rewrite rule

nginx rewrite rule

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:45:22
Original
1543 people have browsed it

实现下面的rewrite:
abc.domian.com/sort/2 => abc.domian.com/index.php?act=sort&name=abc&id=2

nginx.conf里面这么写是正确的吧:
rewrite ^/(.+)\/(\d+)\/?$ /index.php?act=$1&id=$2 last;


回复讨论(解决方案)

基本可以确定你用的CI框架

if (\$request_uri !~ ^/(html|static|favicon/.ico|robots/.txt|index/.php.*) ) {                        rewrite ^/(.*)\$ /index.php/\$1 last;                        break;                }
Copy after login

上面那个是错误的
这个的意思是如果访问 html static等这些静态目录时直接返回,如果不是才需要路由到index.php

if ($request_uri !~ ^/(html|static|favicon/.ico|robots/.txt|index/.php.*) ) {                        rewrite ^/(.*)$ /index.php/$1 last;                        break;                }
Copy after login

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
How to convert apache rewrite to nginx rewrite
From 1970-01-01 08:00:00
0
0
0
nginx - proxy rule conflict?
From 1970-01-01 08:00:00
0
0
0
url-rewrite - Slash problem after nginx directory
From 1970-01-01 08:00:00
0
0
0
nginx rewrite rules do not take effect
From 1970-01-01 08:00:00
0
0
0
url-rewrite - nginx rewrite problem
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