目录的重定向应该怎么写?
有这样形式的URLwww.example.com/abc/1.htmlwww.example.com/bdc/3.html
www.example.com/utf/2.html
若干个,希望重定向到对应的
test.example.com/abc/1.html
test.example.com/bdc/3.html
test.example.com/utf/2.html
abc,bdc,utf这样的目录是已知固定数量的那几个。
不用root 映射,直接用nginx的rewrite 应该如何写?
location ^~/(abc|bdc|utf)/(*.html) {
rewrite ^~/(abc|bdc|utf)/(*.html)https://test.example.com/^~$1/$2permanent;
}
这样写似乎不对,应该怎么写 location /abc {
rewrite ^/acb/(.*)$ http://test.example.com/abc/$1;
}
location /bdc {
rewrite ^/dbc/(.*)$ http://test.example.com/dbc/$1;
}
location /utf {
rewrite ^/uft/(.*)$ http://test.example.com/utf/$1;
} if ( $request_uri ~* ^(/abc|bdc|uft)){
rewrite ^/(abc|dbc|uft)/(.*)$https://test.example.com/(abc|dbc|uft)/$1 last;
}
试试这样看行不
页:
[1]