开发者

nginx multi-stage 404 handling

We just moved to a new site, and want to redirect old links where necessary - however, some still work. For instance,

/holidays/sku.html

still works, while

/holidays/christmas/

no longer works. I'd like to be able to allow the site to attempt to serve a page, and when a 404 is reached, THEN try to pass it through a series of regex redirects, that may look like:

location ~* /holidays/(.*)+$ { set $args ""; rewrite ^ /holidays.html?r=1 redirect; }

I'm using a ~* location directive instead of doing a direct rewrite because we're moving from a Windows-based ASPX site to Magento with php-fpm behind nginx, so we suddenly have to worry about case sensitivity.

Without u开发者_StackOverflowsing nested location directives (which are actively discouraged by nginx documentation) with an @handler of some sort, what's the best way to allow nginx to attempt to serve the page first, THEN pass it across redirects if it fails?

Thanks!


http://wiki.nginx.org/NginxHttpCoreModule#try_files

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜