我最近使用 nginx 设置了一个虚拟主机。托管的网站需要将包含'/old/'
- 的 URL 重定向到不包含 的相同 URL '/old/'
。例如:
www.mywebsite.com/old/a/b/c to www.mywebsite.com/a/b/c
www.mywebsite.com/old/a to www.mywebsite.com/a
www.mywebsite.com/old/a/b/c/d/e to www.mywebsite.com/a/b/c/d/e
有人能给我指明正确的方向吗?谢谢
答案1
答案2
例如:
server {
server_name www.mywebsite.com;
location /old/ {
rewrite ^/old/(.*)$ /$1 permanent;
}
location / {
# bla bla bla and other usual stuff
}
}