简体   繁体   English

break和有什么不一样? 最后 在nginx重写?

[英]what is the difference between break; and last; in nginx rewrite?

i am new in NGINX. 我是NGINX的新手。 moved from apache. 从阿帕奇搬来。 in htaccess apapche it works fine.I already try some converter and didnt work well as on apache. 在htaccess apapche中,它工作正常。我已经尝试了一些转换器,但在apache上效果不佳。 some converter use break other use last.i try a lot hours. 一些转换器的使用中断了其他用途。我尝试了很多小时。 this is my htaccess. 这是我的htaccess。 thanks 谢谢

# 404 ERROR NOT FOUND PAGE
ErrorDocument 404 /404.php

# 301 REDIRECT add WWW
RewriteCond %{HTTP_HOST} ^website.com$ [NC]
RewriteRule ^(.*)$ http://www.website.com/$1 [r=301,nc]

# IP Canonicalization/ change IP to domain name
RewriteCond %{HTTP_HOST} ^111\.222\.333\.444
RewriteRule (.*) http://www.website.com/$1 [R=301,L]

# NO rewrite for exact file/folder name. ex: website.com/index.php and website.com/admin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# modul. ex: website.com/news and website.com/news/page/3
RewriteRule ^([^/]+)/?$ index.php?mod=$1 [QSA,L]
RewriteRule ^([^/]+)/page/([0-9]+)/?$ index.php?mod=$1&page=$2 [QSA,L]

#detail content. ex: website.com/news/123/title-news.html or website.com/news/123/title-news or website.com/news/123
RewriteRule ^([^/]+)/([0-9]+)/[^/]+\.html$ index.php?mod=$1&id=$2 [QSA,L]
RewriteRule ^([^/]+)/([0-9]+)/([^/]+)/?$ index.php?mod=$1&id=$2 [QSA,L]
RewriteRule ^([^/]+)/([0-9]+)/?$ index.php?mod=$1&id=$2 [QSA,L]

thanks so much. 非常感谢。

From the official site: http://wiki.nginx.org/HttpRewriteModule#rewrite 在官方网站上: http : //wiki.nginx.org/HttpRewriteModule#rewrite

difference between break; 中断之间的差异; and last 最后

last - completes processing of rewrite directives, after which searches for corresponding URI and location last-完成重写指令的处理,之后搜索相应的URI和位置

break - completes processing of rewrite directives and breakes location lookup cycle by not doing any location lookup and internal jump at all break-通过完全不进行任何位置查找和内部跳转来完成对重写指令的处理并中断位置查找周期

Module ngx_http_rewrite_module says: 模块ngx_http_rewrite_module说:

last 持续

stops processing the current set of ngx_http_rewrite_module directives and starts a search for a new location matching the changed URI; 停止处理当前的ngx_http_rewrite_module指令集,并开始搜索与更改后的URI相匹配的新位置;

break 打破

stops processing the current set of ngx_http_rewrite_module directives as with the break directive; 与break指令一样,停止处理当前的ngx_http_rewrite_module指令集;

last is usual way and used with rewrites way often than break last是通常的方式,经常与重写方式一起使用,而不是打破

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM