jdn1976

Member
Sep 21, 2020
12
1
1
Brazil
cPanel Access Level
Root Administrator
Hello, I have an issue when I create a redirect using cPanel, gives me an error:

Forbidden
You don't have permission to access this resource.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I made some research, and I try to made manually on .htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com.br$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com.br$
RewriteRule ^.?$ https://example.com.br/site [R=301,L]

and also gives the error:

Forbidden
You don't have permission to access this resource.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I have checked the httpd.conf an it is:
AllowOverride all

So I use an index.html to redirect from http://example.com.br to https://example.com.br/site. But I want to remove this index.html and use the redirect using on .htaccess. But like I said when I try to use on .htaccess gives error 403.

Can you give me some clues what is going on?
 

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
765
310
363
cPanel Access Level
DataCenter Provider
I can't tell you what your error is, but I would not suggest forcing https redirect with the cPanel redirects. You'll end up with a loop if someone is already accessing it via https.

We suggest code like this:

Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
 

jdn1976

Member
Sep 21, 2020
12
1
1
Brazil
cPanel Access Level
Root Administrator
ffeingol

as you instrutions:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com.br/site [R=301,L]

I have added, an it is odd. If I type on browser example.com.br shows the error 403. But if I type on browser www.example.com.br it opens normal and redirect to https://example.com.br/site

Just to add another I use the Uptime robot (UptimeRobot | Free Website Monitoring) to monitor the HTTP service, and when I always add the code to redirect using .htaccess the uptime robot says http is down.
 

jdn1976

Member
Sep 21, 2020
12
1
1
Brazil
cPanel Access Level
Root Administrator
Hello, I have checked on:
intoDNS: checks DNS and mail servers health and there is no error on DNS entries.

my .htaccess:

RewriteOptions inherit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com.br/site [R=301,L]


just to add in order to simulate if .htaccess I change permission of index.html from 644 to 000. This is a simple index:

<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>My Title | Example</title>

<meta http-equiv="refresh" content="1; URL='site/'"/>
</head>
<body>
...
</body>
</html>

and it only works with this index.html. Odd?