Can't get my gitlab pages site working with "www" prefix

Hi, I have created my website with gitlab-pages ans a custom domain, effectivecoding.fr.
I have added the domain effectivecoding.fr in gitlab. The site works well with : effectivecoding.fr, secured with let’s encrypt. :grinning:

Unfortunately, it does not work when I go to www.effectivecoding.fr : I have a 401 Error “- You don’t have permission to access the resource.”

My name server is OVH, and I have followed this documentation : https://docs.gitlab.com/ee/user/project/pages/custom_domains_ssl_tls_certification/#for-both-root-and-subdomains , with this configuration :

I also tried with 2 separate domains in Gitlab : effectivecoding.fr and www.effectivecoding.fr, but the lets’s Encrypt certificate can not be validated for the second domain, and so https is not working.

Do you have any idea?

Thank you in advance,

3 Likes

Hi @Sylvain, did you manage to solve this issue? I have the same problem (also using OVH) and none of the solutions I found on the forum helps :confused: I added my root domain with DNS A record and TXT verification successfully (so https://mydomain.com works fine and is encrypted), but cannot do the same for www.mydomain.com. I tried:

  1. adding CNAME www to namespace.gitlab.io - resulted in 401 error
  2. adding www.mydomain.com as New Domain and and TXT verification passed, but I can’t validate Let’s Encrypt and when I enter www.mydomain.com I got error “DNS_PROBE_FINISHED_NXDOMAIN” (in all browsers and devices). Only if I add DNS A record it works, but it means I treat www the same as my root domain, is that correct?

Also I didn’t understand why the documentation suggest adding both TXT and CNAME for subdomain www.example.com - when I try to do this in my DNS zone I got error stating I can’t add both TXT and CNAME records for one subdomain (sorry if it’s obvious, but I’m a total rookie).

1 Like

Even I have the same problem. I use mydomain.com is working fine for me. TXT verification with mydomain.com is passed with Gitlab. I added CNAME record for redirecting www.mydomain.com to mydomain.com, but still, I am getting the error " 401

You don’t have permission to access the resource." one of Gitlab permission errors. @AlexC , @Sylvain any leads on this?

FYI, I use Google domains to get the domain name.

I have this issue as well.

mydomain.com works fine, but www.mydomain.com does not resolve.

I’ve tried following these steps with no luck.

The same for me, before with OVH and now that I’ve migrated to AWS Route 53 is the same issue.

I’m seeing this issue. CNAME entry for www subdomain yields the error message mentioned above from gitlab " You don’t have permission to access the resource."

I think it has to do with the pages being in a project url, as in: groupname.gitlab.io/projectname

I fixed this for my site by adding the “www” version of the name as a separate domain.

  1. Go to Deployments → Pages
  2. Click “New domain”
  3. Enter “www.mydomain.com
  4. Create a new TXT verification record in DNS when prompted. This is not the same verification code as for “mydomain.com, even though the example in the documentation uses the same value for both.
  5. Back in Gitlab, click the Retry Verification button (looks like a curly arrow).
  6. If you are using Let’s Encrypt certificates, then https://www.mydomain.com should start working after a few minutes.
1 Like

@alistairmgreen Can confirm that this worked for me.