Nginx Url重写

目标:将url重写为应用程序兼容格式

进展:我有一个从根域工作正常,但是当我添加/ foo /或/ bar /我只是得到一个404,因为它试图匹配我的configuration中的位置。

例如..

http://domain.com/#工作正常

http://domain.com/foo/#获得404 – 我认为它是不符合位置

我有应用程序的url,我已经添加了$ request_uri到最后,但是我想能够通过/ foo /或/ bar /到url,使其正常工作。

我已经尝试了$ request_body $ request_uri $ 1并改变组合,但是没有运气只是一个404。

我怎么去做这个? 哪个$variables我需要传递到URL?

下面的url的一个例子。 不是确切的,但希望足以得到一个想法。

location / { rewrite ^/$ pt/Wondering?virtual-webr00t=http://foobar.com&pagename=123/Dispatcher&url-path=$request_uri` last; } location /pt/Wondering { proxy_pass http://domain.com; proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; root html; } 

你的问题是你正在使用下面的

 rewrite ^/$ # Starts with / and ends with / 

当你应该使用

 rewrite ^/ # start with / and accepts anything afterwards 

区别在于正则expression式。