我想改变这些:
http://www.ltv.com/iloveu/health/contraceptionsurvey/
http://www.ltv.com/iloveu/health/contraception-special/
location ~* ^/iloveu/health/contraceptionsurvey/?$ {
rewrite ^ /ilo`enter code here`veu/health/ permanent;
}
location ~* ^/iloveu/health/contraception-special/?$ {
rewrite ^ /iloveu/health/ permanent;
}
使用我创建的表达式:
%s/http:\/\/www\.ltv\.com\(.*\)/location ~\* \^\& \{ \r\t rewrite \^ \/iloveu\/health\/ permanent; \r }\r/g
但似乎没有获得所需的输出。
答案 0 :(得分:1)
%s#http://www\.ltv\.com\(.*\)#location \~* ^\1?$ \{ \r\t rewrite ^ /iloveu/health/ permanent; \r }\r#g
\&
获取匹配的整个字符串,而不只是括号中的部分,您可以使用\1
获得该字符串。