Forcing Https Redirect Issuse

I read the article about forcing the http to https and I added the code it said to add to my .htaccess file and my site stopped working… here are the contents of my .htaccess file…

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 %{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 %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


UPDATE: I changed the last three lines of code to:

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

the force redirect happens but now my site doesnt load… anyone know how to fix this issue?

You may want to remove that second RewriteEngine On from the file. Whenever that line is run, any rewrite rules set previously are cleared. This is a useful feature in some cases (e.g. when you’re installing another script in a subdirectory). But in this case, it also removes the rewrite rules of your own software.

2 Likes

for some reason now it went back to directing to http instead so I redirected it using the redirect now it is pointing to https but the content is showing the too many redirect error, any ides how to fix this?

Do not use the redirects tool to redirect to your own domains. It will just create a redirect loop. Remove the redirect you added through the tool and don’t touch the tool again.

Looking at your .htaccess code, maybe you need to move the .htaccess code for the HTTPS redirect above the existing rewrite rules. So just below the last </FilesMatch> line. Your current .htaccess rules may capture the request before it matches the HTTPS code.

2 Likes

I did that and now my .htaccess looks like:

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>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

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

now it seems to direct to https but now I get no content and the error says " |Message:|SQLSTATE[HY000] [2002] Connection refused|
| — | — |
|File:|/home/vol9_5/epizy.com/epiz_25485944/collabplanet.online/htdocs/ow_core/database.php| "

That error means there is an issue with your database connection. So I think these .htaccess rules are fine, and this is another issue.

Do you experience that error consistently or occasionally?

3 Likes

yes it does happen consistently lately I would say

I’m sorry, I should have been more specific.

Do you experience this issue on every page and all the time? Or does it work sometimes and other times it doesn’t?

1 Like

well currently none of my site is showing so its on every page all the time right now, https://collabplanet.online is the link if it would help to see the problem im talking about

For me it throws an ERR_TOO_MANY_REDIRECTS error. Please remove all of your redirect codes from the “Redirects” section of the Control Panel, and then correct your .htaccess file to have these rules instead:

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
1 Like

i made sure there werent any redirects in the control panel and changed the .htaccess code but nothing seems to have changed on my site. I still get that same error

I did some testing on your account, and even when I remove all .htaccess related code, your site appears to enforce non-HTTPS URLs on your site. Can you please check the configuration of your website to see if it has any way to configure HTTPS or website URLs? Because enforcing HTTPS in your .htaccess file won’t get you anywhere if your website code then enforces HTTP.

1 Like

I did see where to adjust that but now im looking into the ssl error its saying

I believed I fixed the ssl issue but im getting an erro that says it cant find the master page when I try to visit the site. Any idea whats causing this?

I checked your site, but I see a login page without any errors.

And “master page” sounds like it would be a function of the website software you’re using. So you may want to search the web for error message with the name of the software.

1 Like

yeah but now its back to not pointing to https… any ideas on the fix for that?

Are you using Let’s encrypt?

If so, use this code:

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

1 Like

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