Redirect www.example.com to https://example.com (without www)


#1

Hello community,

I have one issue with redirecting w w w. m i l e m i j a t o v i c . c o m to h t t p s : / / m i l e m i j a t o v i c.c o m, however when I want to access to my site without www , it’s properly redirected to the
h t t p s : / / m i l e m i j a t o v i c .c o m

DNS and HTTP Proxy (CDN) is turned on for “A” which is my domain m i l e m i j a t o v i c .c o m and “CNAME” which is www - Value is an alias of m i l e m i j a t o v i c .c o m

SSL - milemijatovic.co m, *.milemijatovic.co m (2 hosts) Universal (Shared)

Always use HTTPS - Turned on
Automatic HTTPS Rewrites - Turned on

Can you help me how to fix this little issue? Do I need to add new page rule or … ?

Sorry I wrote .co m because I can not use more than two links as new user. Thank you


#2

Works perfectly for me. Both http://milemijatovic.com and http://www.milemijatovic.com redirect to their https equivalents.


#3

Thank you for your reply… but it is an issue when you enter www.milemijatovic.com, should be redirected to the https://milemijatovic.com without www

How to fix that? Can you help me?


#4

It does work properly (for me). “www” gets stripped off when I use HTTP or HTTPS. All combinations ultimately lead me to https without the www.


#5

Yes, everything is ok now.

I solve with this line of code in .htaccess file

RewriteBase /
RewriteCond %{HTTP_HOST} ^www.(.*) [NC] RewriteRule ^(.*) http://%1/$1 [R=301,L]


#6

I would change the RewriteRule to point to https instead of the default http. It’ll strip the www and redirect to https all in one swoop.


#7

Ok, thank you for suggestion , can you tell me how to do that? I currently have issue with google analytics, I am not sure does it affects the fact that the google analyst does not show any visitors in real time?


#8

Edit that line of code in .htacess to change the http:// so it says https://
Use whatever editor you just used when you added that line.

Ah, Google Analytics. Is it set up for the www domain? I don’t use Google Analytics, but as I recall from their Webmaster Tools, you need to specify if it’s a www or non-www domain you’re analyzing. Looking at my webmaster tools console, my sites are configured as https.

So…log into Google and make sure you’re using https and not using www.


#9

Ok, I changed http:// to https:// in .htaccess. Thanks for the advice.

In google analytics, no, its not www, I use https://milemijatovic.com

I am not sure why real time overview is not displayed :confused:


#10

How about trying the new Google Analytics app here at Cloudflare? You’ll have to turn off your site’s current Analytics code so it doesn’t double-count or conflict.


#11

Just a moment. For some reason, my google analytics now works properly :slight_smile:

Thanks


#12

Didn’t work for me. I even updated my database url info after the .htaccess

I’m having issues with redirects with my GTmetrix results, and it’s not being redirect for https://example.com (without www).

Avoid landing page redirects for the following chain of redirected URLs.

http://example.com/
http://www.example.com/
https://www.example.com/


#13

@sdayman isn’t it more efficient to do 301 redirects with a Page Rule instead of .htaccess? Like this:


#14

I doesn’t work. I get the “ERR_TOO_MANY_REDIRECTS” warning.