简体   繁体   English

Nginx substring 可以 $request_uri 吗?

[英]Can Nginx substring the $request_uri?

I want to substring $request_uri我想 substring $request_uri
For example, The URL address is:https://example/surveyssl/survey例如URL地址为:https://example/surveyssl/survey
If I using $request_uri, it will get "surveyssl/survey"如果我使用 $request_uri,它将得到“surveyssl/survey”
Can I substring "surveyssl" so that I can get "survey" only?我可以 substring “surveyssl” 以便我只能获得“调查”吗?

location /surveyssl/survey{
             proxy_pass http://ssldev/surveyssl/index.php/$request_uri;
             #It will fail because the url output is 
             #http://ssldev/surveyssl/index.php/surveyssl/survey
             #but I want to get this url:
             #http://ssldev/surveyssl/index.php/survey
 }

With your shown sample, could you please try following.使用您显示的示例,您能否尝试以下操作。 Please make sure to clear your browser cache before testing your URLs.请确保在测试您的 URL 之前清除您的浏览器缓存。 First ruleset is very specific one to catch only surveyssl;第一个规则集非常具体,只捕获调查; 2nd rules set it dynamic one where it will catch anything coming after surveyssl.第二条规则将其设置为动态的,它将捕获调查后出现的任何内容。

location ~ /surveyssl/(survey/?) {
             proxy_pass http://ssldev/surveyssl/index.php/$1;

 }

EDIT: To make it dynamic try following rules:编辑:要使其动态尝试以下规则:

location ~ /surveyssl/([\w-]+/?) {
             proxy_pass http://ssldev/surveyssl/index.php/$1;

 }

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

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