2

I'm having trouble redirecting www to non-www links using Namecheap. I added a URL Redirect Record with a host of www and a value of http://example.com which works fine for the main (and mostly only page).

The problem is that I'm setting up SSL using Let's Encrypt and it needs to verify using the file served at www.example.com/.well-known/acme-challenge/whatever. But the way the redirect rule currently works is that I have it redirects every URL to http://example.com (the homepage) instead of just removing www from the current URL. This obviously breaks the Let's Encrypt setup since it can't verify that page using www since it redirects to the homepage instead.

If it matters I'm hosting this site on GitLab Pages so my other rule is an A Record with host @ and value 52.167.214.135. But seeing as my non-www URLs work fine I don't think this rule is causing an issue. Any ideas?

migrated from superuser.com Feb 14 '18 at 10:50

This question came from our site for computer enthusiasts and power users.

  • After some more thought I believe the solution would be to remove the URL redirect record, add another A record with host www pointing to the GitLab Pages IP, and then add www.fakewebsiteaddress.com as a custom domain in the GitLab Pages settings alongside fakewebsiteaddress.com. Unfortunately GitLab has discovered a security flaw in their custom domain validation so I won't be able to test this theory for a while. – SilverSerpent Feb 14 '18 at 7:35
4

https://www.namecheap.com/support/knowledgebase/article.aspx/385/2237/how-do-i-set-up-a-url-redirect-for-a-domain documents NameCheaps redirecting rules:

It is important to note that the value in the Destination URL affects where and how the URL is redirected.

Host: www1.example.net
Destination: http://example.com

Host: www2.example.net
Destination: http://example.com/

In the first case, www1.example.net will not pass values to the destination URL, so www1.example.com/xyz.html will redirect users to http://example.com only. Thus, all values that you put in the original URL under your domain name will be left out.

In the second case, www2.example.net/xyz.html will redirect users to http://example.com/xyz.html (pay attention to the symbol "/" in the configuration). All values that are put into the original URL under the domain name will be included in the destination address and applied in the results.

You have to add the trailing slash on the destination URL to get NameCheap to preserve URL paths.

  • Thanks Stephen, this trick works for me. But there is still a issue, it seems namecheap URL redirect only will work with HTTP. Access https://example.com or https://example.com/xyz.html will just be hanged there. – leon Oct 22 '18 at 5:31
  • Most redirect services don't support HTTPS. If you want to support HTTPS you will need a security certificate for the redirecting site. I've never seen a free redirect service that supports HTTPS. – Stephen Ostermiller Jan 4 at 10:17

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.