How to provide redirect for this scenario? #127192
-
Select Topic AreaQuestion BodyWe have configured the following repository with a CNAME record to use https://opensource.hcltechsw.com as the public URL. We have to now change the domain to https://opensource.hcl-software.com. I think when the CNAME record is updated with the new domain, users will be able to access https://opensource.hcl-software.com. However, how can i ensure that users accessing the old URL (https://opensource.hcltechsw.com) are redirected to the new URL (https://opensource.hcl-software.com)? Syed |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
GitHub Pages does not maintain custom domain redirections upon changes. There are many different solutions if you don't use GitHub Pages, but here is how I would do it on Pages:
|
Beta Was this translation helpful? Give feedback.
-
@yoannchaudet Thanks for the response. I have set up new org>repo for opensource.hcl-software.com. It contains an index.html file with redirect to opensource.hcltechsw.com. The redirect works fine when i access https://opensource.hcl-software.com it takes me to https://opensource.hcltechsw.com. However, when i access https://opensource.hcl-software.com/folder/page.html, there is no redirect to https://opensource.hcltechsw.com/folder/page.html. Could this be because /folder/page.html does not exist in opensource.hcl-software.com but it exists only in opensource.hcltechsw.com? Given that opensource.hcl-software.com contains only index.html, I am looking forward to any of these solutions:
Thanks... |
Beta Was this translation helpful? Give feedback.
-
@yoannchaudet Any input on page level redirect? I can think of adding redirect meta tag to all the pages but is there an efficient way? |
Beta Was this translation helpful? Give feedback.
GitHub Pages does not maintain custom domain redirections upon changes.
There are many different solutions if you don't use GitHub Pages, but here is how I would do it on Pages:
Create a new repository (e.g. by cloning your existing repo) and setup Pages to use the new domain you intent to use
On your previous repo (i.e. setup to point to your previous URL), remove all content but leave a single
index.html
(and404.html
) file containing the same content: a meta HTTP redirect (doc). When someone access this old URL (or any path on it that would result in a 404 error), they will be redirected to your new URL. It's not perfect but should handle most things.