user2636197
user2636197

Reputation: 4122

www domain redirects to none www domain using cloudflare

I am using Cloudflare and Digitalocean. I have setup my name servers and in Cloudflare I have these settings:

A: mydomain.com -> 1.2.3.4.5 

CNAME: www -> mydomain.com

But when I visit my site by www.example.com I get redirected to:

https://example.com

So how can I keep the www part in my domain?

Upvotes: 0

Views: 263

Answers (2)

Pedram Ezzati
Pedram Ezzati

Reputation: 325

You should go to page rules as below

enter image description here

There are two kind of redirect

  Permanet redirect 301
  Temporary redirect 302

Example

As you can see in below Picture all request to www.xxx.info will redirect to xxx.com

here * means all Paramter will accepted by cloudflare and put in place of $1 in redirect URL

enter image description here

Upvotes: 1

mjsa
mjsa

Reputation: 4399

The only way to insert HTTP redirects in Cloudflare is currently via Page Rules. If you don't have a redirect set in your Page Rules than this redirect must be on your Origin server.

As this is the case you will need to alter this in your application. For example, on WordPress you can do this in the admin dashboard (Settings > General, then changing the URLs there to include WWW).

WordPress URL options

Upvotes: 2

Related Questions