How to redirect www to non-www for Subdomains

I am having a problem to redirect www to non-www for Subdomains…

Before deploying Cloudflare - I had redirects in my .htaccess file (for my Drupal site) and they were working…

After enabling Cloudflare - they doesn’t work - for Subdomains; the site root is OK;

I was following this tutorial Redirect www.example.com to example.com

I created my first page rule:

www.*.myname.com/*

Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://*.myname.com/$1)

because I thought it would be for subdomain; but I didn’t see any difference, so later I added also the default example:

www.myname.com/*

Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://myname.com/$1)

I still can’t see any difference, or may be I have to wait for it to start working?!

Also, in Cloudflare tutorial it said I should add DNS entry as A www IPnumber auto proxy;

  • I did this, but I had to delete the original CNAME www MyName.com auto DNS only?! - because it was showing I cannot have both CNAME & A entries for WWW?! - This was confusing…

so, yah, I am looking for Subdomains (keyword.myname.com ), I have not any issue with mother domain;

Without an actual example, we can’t troubleshoot, but it’s probably this:

This one:
Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://*.myname.com/$1)
Should be written like:
Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://$1.myname.com/$2)

That way the first wildcard is forwarded as the subdomain, and the second wildcard is forwarded as the path.

1 Like

I am trying, but no luck;

I can give you actual examples, if you can test…

Neither of those ‘www’ hostnames resolve, so they’re not in your Clouflare DNS records page.

Even if they resolved, they’d have to be proxied for the Page Rules to work, and without SSL as mentioned in the Tutorial, they’re not likely to work.

OK, Thank You!

I woke up and realised my error - I didn’t create at all the www.subdomain A record, now it is working by redirecting http://www to https://subdomain. , except the NO_Cypher_Overlap error for https://www.subdomain

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.