[英]How to make a link redirect to a location with nginx
I am having a problem with trying to serve two different sites using the same server. 尝试使用同一服务器为两个不同的站点提供服务时出现问题。
I have a landing page at the root of timothylim.is and a separate blog at timothylim.is/writing . 我有根的登陆页timothylim.is ,并在一个单独的博客timothylim.is/writing 。
I have the following nginx configuration with two different locations: 我有以下两个不同位置的nginx配置:
location / {
rewrite ^/pserver(/.*)$ $1 break;
proxy_pass https://timothyylim.github.io/landing-page/;
}
location /writing {
rewrite ^/pserver(/.*)$ $1 break;
proxy_pass https://timothyylim.github.io/writing-online/;
}
However, when any of the links are clicked on the '/writing' location the browser navigates to timothylim.is/poetry/your-pillar/ instead of timothylim.is/writing/poetry/your-pillar/ . 但是,当在“ / writing”位置单击任何链接时,浏览器将导航到timothylim.is/poetry/your-pillar/而不是timothylim.is/writing/poetry/your-pillar/ 。
Is there a way to redirect to a subfolder on the main domain? 有没有办法重定向到主域上的子文件夹?
您可以使用基本元标记,而不是尝试更改服务器行为。
<base href="timothylim.is/writing/">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.