小编mrm*_*rm8的帖子

nginx:将子文件夹重定向到子域

我正在尝试将子文件夹重定向到 nginx 中的子域。我希望http://example.com/~meow/被重定向到http://meow.example.com/。我尝试了以下方法:

location ~ ^/\~meow/(.*)$ {
    rewrite ^(.*)$ http://meow.example.com$1 permanent;
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用。它被我的用户目录的位置块捕获:

location ~ ^/~([^/]+)/(.+\.php)$ {
    [...]
}

and

location ~ ^/\~([^/]+)/(.*)$ {
    [...]
}
Run Code Online (Sandbox Code Playgroud)

那么,我该怎么做呢?哦,我只想 /~meow/ 被重定向。不应更改所有其他用户目录。

nginx directory redirect subdomain

5
推荐指数
2
解决办法
5959
查看次数

标签 统计

directory ×1

nginx ×1

redirect ×1

subdomain ×1