.htacccess

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Anti-Spam Guide
Post Reply
HappySailor
Registered User
Posts: 4
Joined: Fri Jan 05, 2018 6:24 pm

.htacccess

Post by HappySailor » Sun Jan 07, 2018 4:56 pm

Hey friends,

on my site I use phpBB as a support forum. I would like to redirect all traffic to always use https, instead of http. Generally on my site this works fine, but as phpBB comes with its own .htaccess file, I guess that it needs some tweaks.

What I did was I added the code below at the bottom of the phpBB .htaccess file, and it seems to do its job just fine, but I was wondering if any problems might occur that I haven't thought of, using that solution.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

User avatar
3Di
Registered User
Posts: 12749
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: .htacccess

Post by 3Di » Mon Jan 08, 2018 1:59 am

In your .htaccess file (YOUR_FORUM_ROOT/.htaccess) after the first 2 lines

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine on
ADD, AFTER (on a new line)

Code: Select all

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
The final result would be

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
SAVE the file.

In ACP/cookie settings - set cookie secure to ENABLED.

Note:
the last bit [R,L] doesn't contain the 301 redirect (which is permanent), best to change this bit after you really realised everything went fine, otherwise your links will be permanently redirected also if wrong and search engines are not often visiting a site, therefore, updating links... that could lead to issues.

Once you know, can be changed to [L,R=301].

That code seems to be the best solution, saved many others' days here.
Have a look at the server port in ACP, should be 443 (in some case depends on wrong server settings though).

To test, visit another site where you posted a link to your site under HTTP, should redirect to HTTPS.

As well the above code redirects any www.site.xxx - site.xxx - http://site.xxx - http://www.site.xxx to their relative HTTPS.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

Post Reply

Return to “phpBB Discussion”

Who is online

Users browsing this forum: Gingko, hewmac06 and 53 guests