Answer a question

I want to substring $request_uri
For example, The URL address is:https://example/surveyssl/survey
If I using $request_uri, it will get "surveyssl/survey"
Can I substring "surveyssl" so that I can get "survey" only?

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
 }

Answers

With your shown sample, could you please try following. Please make sure to clear your browser cache before testing your URLs. 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;

 }
Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐