SOLVED Setting up redirection for https issue

G. Andore

Registered
May 30, 2018
4
0
1
Guatemala
cPanel Access Level
Website Owner
Hello Team,

I've created a redirection on my Cpanel as shown below on the pictures attached but I am getting the error below.

This page isn’t working
example.com redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS

I selected this on Cpanel:
Code:
Type: permanent 103
https?://(www.)?: example.com
Blank space on /
Redirects to: https://example.com
Redirect with or without www.
Selecting Wild Card Redirect.
My goal is that when anyone types
Code:
 'example.com' or 'www.example.com'
they got directly to
Code:
 https://example.com
secured site and it's working good with SSL but I want to fix those 2 addresses. Thanks for the help!
 

Attachments

Last edited by a moderator:

Dave Smith

Active Member
Mar 20, 2016
44
12
8
Lisbon
cPanel Access Level
Root Administrator
Hi,
You could try undoing your changes above and uploading a .htaccess file containing the following (or enter the below in to your current .htaccess file at the top).

Code:
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
See if that helps..?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Hello @Dan70,

I'm glad to see the issue is now solved. Thanks for sharing the outcome!
 

G. Andore

Registered
May 30, 2018
4
0
1
Guatemala
cPanel Access Level
Website Owner
Hi,
You could try undoing your changes above and uploading a .htaccess file containing the following (or enter the below in to your current .htaccess file at the top).

Code:
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
See if that helps..?
Hello @Dave Smith and @cPanelMichael

I've tried doing what you did but it happened the same issue I mentioned above. ERR_TOO_MANY_REDIRECTS.

Can you be so kind to take a look on the code I sent below took from my htaccess and let me know if something is wrong. Or should I replace the current values for the ones you've shared?

Code:
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteOptions inherit

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress