VPS侦探论坛
标题:
目录的重定向应该怎么写?
[打印本页]
作者:
puffbaby
时间:
2018-5-1 17:48
标题:
目录的重定向应该怎么写?
有这样形式的URLwww.example.com/abc/1.html
www.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/$2 permanent;
}
复制代码
这样写似乎不对,应该怎么写
作者:
YaoLing
时间:
2018-7-16 15:47
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;
}
作者:
YaoLing
时间:
2018-7-16 15:49
if ( $request_uri ~* ^(/abc|bdc|uft)){
rewrite ^/(abc|dbc|uft)/(.*)$ https://test.example.com/(abc|dbc|uft)/$1 last;
}
试试这样看行不
欢迎光临 VPS侦探论坛 (https://bbs.lnmp.com/)
Powered by Discuz! X3.4