Help solve the problem with http and https (redirects)

I got ssl certificate and connected it to the site. I now have to do a gluing of the http and https versions of the site. At first I did redirects, but I got an error in the browser: the site made too many redirects (I read on the Internet that this means that the site endlessly redirects from the http version of the site to the https version of the site and vice versa). I rummaged through the forum and changed the contents of my .htaccess file:

redirectMatch 301 ^(.*)$ https://ogefizika587.ml/
Options +FollowSymLinks
RewriteEngine On
AddEncoding gzip .gz
AddEncoding gzip .gzip
<FilesMatch "\.(js.gz|js.gzip)$">
  ForceType text/javascript
</FilesMatch>
<FilesMatch "\.(css.gz|css.gzip)$">
  ForceType text/css
</FilesMatch>
RewriteCond %{HTTP:X-Forwarded-Proto} http [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,NC]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/
RewriteCond %{REQUEST_URI} !/ow_cron/run\.php
RewriteCond %{REQUEST_URI} !/e500\.php
RewriteCond %{REQUEST_URI} !/captcha\.php
#RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteEngine On
RewriteCond% {SERVER_PORT} 80
RewriteRule ^ (. *) $ Https://www.ogefizika587.ml/$1 [R, L]

But now when I try to switch to the https version, I see only the inscription in the lower left corner (Google Chrome):
“Waiting for a proxy tunnel to be created,” and nothing happens for a long time. Then an error occurs: 500 Error, please check your php script / enable display_errors in your cpanel.
Please help me solve the problem!

Changed the .htaccess file:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Now he gives this error: Unable to access the site The web page at https://ogefizika587.ml/ may be temporarily unavailable or constantly moved to a new address.
ERR_TUNNEL_CONNECTION_FAILED

Hello,

Could you try this one:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

It always works for me unless you probably misconfigured something.

Hope this helps!

1 Like

It’s something wrong about the “redirect match” part that the cpanel is adding incorrectly, only @Admin can fix this.

Remove the redirect match code from the .htaccess file, and your problem should be solved.

2 Likes

Don’t use the redirects tool to redirect to the same domain. Redirecting a domain name back onto itself is kind-of the definition of a redirect loop. If you still have this line in your config, you should delete.

It’s not necessarily “wrong” code. It’s fine if you’re redirecting to another site. Just don’t use it to redirect to the same domain.

Do you use some kind of network proxy to access the internet? Because that error sounds like it’s your proxy that’s not behaving correctly. That’s not related to your hosting account or website.

1 Like

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