MyBB Community Forums

Full Version: redirect to https only (htaccess question)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi friends,

I installed a fresh latest build MyBb, I noticed there is htaccess.text file in the root, so I have renamed it to .htaccess but still my site redirects without http even I have setup https in the site admin panel.

I did read some of threads here but could not fix it, please advise how I can redirect my site to https://mydomain.today/ I do not want the www in it also Smile
To redirect your MyBB site to HTTPS, you can add the following code to your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This code checks if HTTPS is off and then redirects the user to the HTTPS version of the website.

To also remove the "www" from your URL, you can modify the code as follows:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This code first checks if the URL starts with "www." and redirects to the same URL without "www.". Then, it checks if HTTPS is off and redirects to the HTTPS version of the website.

Make sure to clear your browser cache before testing the changes.