English 中文(简体)
Nginx: Using the Trial_files Directive to establish a pretty URLs
原标题:Nginx: Using the try_files Directive to create a pretty URLs

我想要的是E/widget/ rafter IE:

www.site.com/widget/1/2/3

rewritten as

www.site.com/index.php?type=widget&a=1&b=2&c=3

using the try_files directive

a. 植被外的任何档案:

www.site.com/cool_stuff.php 

should be unaffected by this rewrite

多次失败的努力 我无法做到这一点。 任何帮助都值得赞赏!

最佳回答

try_files receives a list of arguments representing which files Nginx should pass the request on to. For example: try_files $uri $uri/ index.php =404 informs Nginx that it should try to match a request against $uri (the requested path as a file name, post-rewrites) $uri/ (the requested path as a directory, post-rewrites), then to try index.php, and if all else fails, return an HTTP 404 Not Found error code. Another example: to map every request to a index.php, regardless of it s URI, use try_files index.php =404;.

在这种情况下,我不认为是你要求的最佳指令。 相反,考虑使用改写规则将<代码>/widget/1/2/3改为/index.php?type=widget&a=1&b=2&c=3

问题回答

暂无回答




相关问题
URL rewrite in IIS6 - Third party tools

I have collected the following api/sdk/whatever which provide modules for doing url rewriting in IIS 5/6/7. Some are free-open source and some require $. I haven t tried any of them. I would like to ...

Rewrite spring-security redirect URLs

I m trying to get Tuckey UrlRewriteFilter to tidy up URLs for my webapp. One problem I ve got is that when spring-security notices that an anonymous user is trying to access a protected resource it ...

ASP.NET Friendly URLs

In my research, I found 2 ways to do them. Both required modifications to the Application_BeginRequest procedure in the Global.Asax, where you would run your code to do the actual URL mapping (mine ...

Could I get by HttpModule the URL that contains * before?

My web-site is working under ASP.NET 3.5, IIS7, Integrated pipiline mode. My HttpModule is getting request to all resources, including URLs like this: http://my-site.com/address And I would support *...

Domains & Foreward Slash

This is rather difficult to explain so please bear with me. We will be hosting 4 websites on our server and the plan is to have each site sit under its own domain: site-a.com site-b.com sub1.site-b....

URL Mod-Rewrite

I currently have a working URL: http://example.com/security-services.php?service=fixed-camera-surveillance and then I have PHP say, $_REQUEST[ service ] to do some stuff... But I d like to ...

热门标签