I’ve heard about using a 301 redirect, but I’m struggling to locate the Nginx configuration directory on my server. Any alternative solutions or guidance would be greatly appreciated.
Thank you @Lilly. I’d like to know if permalinks can handle a full domain change too. Just to clarify, we’re moving from abc.domain1.com to xyz.domain2.com. Both the subdomain and the domain are changing. I’ve been reading through this discussion and wanted to confirm:
Are you trying to redirect an existing Discourse topic to an external URL? That’s not what permalinks are designed to do. I’m pretty sure that you can’t redirect anything under /t.
If you want people who visit https://hoidap.cheng.vn/t/cach-cua-do-nu-bao-binh-don-gian/70 2 to be redirected to https://cunghoangdao.info then I think your best bet is to edit the post and tell people to click the link to go to the other site.
Thank you @RGJ for the guidance. I just ended up doing a domain level direct from our domain name provider, and that worked. The old links are redirecting to the new links correctly.
Here is the method I use for a full redirection after a domain change, I mixed a few solutions offered in this forum.
in the app.yml, at the end I add the after_web_config and after_ssl blocks :
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- git clone https://github.com/discourse/docker_manager.git
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/discourse_redirect_1.conf
contents: |
server {
listen 80;
listen 443 ssl;
server_name old-domain.com;
return 301 $scheme://new-domain.com$request_uri;
}
after_ssl:
- replace:
filename: "/etc/runit/1.d/letsencrypt"
from: /--keylength/
to: "-d old-domain.com --keylength"
## Any custom commands to run after building
run:
- exec: echo "Beginning of custom commands"
## If you want to set the 'From' email address for your first registration, uncomment and change:
## After getting the first signup email, re-comment the line. It only needs to run once.
#- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
- exec: echo "End of custom commands"
It will redirect the old links to the new forums, without a SSL issue.