从“着陆页”插件中,我有一个要用作主页的页面:
forums.mysite.com/landing -
因此,当人们访问 mysite.com 或 www.mysite.com 时,我希望他们被重定向到 forums.mysite.com/landing。
现在,如果有人输入错误并访问 forum.mysite.com/landing(“forums”中没有“s”),我希望他们被重定向到 forums.mysite.com。
在 Discourse 的 app.yml 文件中,我设置如下:
after_web_config:
- replace:
filename: /etc/nginx/nginx.conf
from: /sendfile.+on;/
to: |
server_names_hash_bucket_size 64;
sendfile on;
- file:
path: /etc/nginx/conf.d/forumsredirect1.conf
contents: |
server {
listen 80;
server_name mysite.me;
return 301 $scheme://forums.mysite.me/landing$request_uri;
}
- file:
path: /etc/nginx/conf.d/forumsredirect2.conf
contents: |
server {
listen 80;
server_name www.mysite.me;
return 301 $scheme://forums.mysite.me/landing$request_uri;
}
- file:
path: /etc/nginx/conf.d/forumsredirect3.conf
contents: |
server {
listen 80;
server_name forum.mysite.me;
return 301 $scheme://forums.mysite.me$request_uri;
}
在我的域名的 DNS 记录中,我有:
这一切都正确吗?我猜不正确,因为目前,当我访问 mysite.com 时,它是一个死页面。但是,www.mysite.com 可以正确重定向,但不是重定向到我的 /landing 页面,而是只重定向到基础的 forums.mysite.com 页面,而且这只是部分有效,我猜是因为我的域名主机上的 DNS 记录而不是我的 VPS app.yml 文件……救命?
我可以在这里(我的基础域名)添加多个主机名以使其正常工作,还是有什么问题?

