Force https and www

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
Holger
Registered User
Posts: 1711
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Force https and www

Post by Holger » Mon Mar 25, 2019 4:04 pm

Hi there,

I would like to force https and www in the URL.
I have this in the .htaccess:

Code: Select all

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.domain.com%{REQUEST_URI} [NC,L,R]
http://domain.tld results in https://www.domain.tld OK
http://www.domain.tld results in https://www.domain.tld OK
BUT
https://domain.tld results in https://domain.tld and NOT in https://www.domain.tld NOT OK

I am sure the tweak in .htaccess is easy, but I cannot find anything.

Can anyone please help me? Thanks!

/Holger
Last edited by Mick on Tue Mar 26, 2019 11:50 am, edited 1 time in total.

User avatar
Raul [ThE KuKa]
Style Customisations
Style Customisations
Posts: 5991
Joined: Mon Dec 08, 2003 9:24 pm
Location: Spain
Name: Raul Arroyo
Contact:

Re: Force https and www

Post by Raul [ThE KuKa] » Mon Mar 25, 2019 6:38 pm

Read this topic please:
viewtopic.php?f=556&t=2501786

Best regards.
All unsolicited PMs will be ignored.
:warning: Knowledge Base | Documentation | Board rules | phpBB Styles Rules & Policies :warning:


If you like my styles, translations, etc. and want to show some appreciation, then feel free to Donate with Image
:flag_es: phpBB Spain - Online Since 2003 :heart:


🎨 phpBB Professional Premium Themes 🔥

Holger
Registered User
Posts: 1711
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Re: Force https and www

Post by Holger » Tue Mar 26, 2019 11:22 am

Thanks! :)

Holger
Registered User
Posts: 1711
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Enabling Free SSL with .htaccess

Post by Holger » Tue Mar 26, 2019 11:23 am

*delete*

Holger
Registered User
Posts: 1711
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Re: Force https and www

Post by Holger » Tue Mar 26, 2019 11:55 am

(Huh? Posted a question in the other topic (linked by Raul) and it showed up in this topic again?!)

User avatar
spaceace
Registered User
Posts: 1829
Joined: Wed Jan 30, 2008 8:50 pm
Contact:

Re: Force https and www

Post by spaceace » Wed Mar 27, 2019 9:13 am

here's how i force www for my site

Code: Select all

## Force www ##
RewriteCond %{HTTP_HOST} ^livemembersonly.com [NC]
RewriteRule ^(.*)$ https://www.livemembersonly.com/$1 [L,R=301,NC]
## Force www ##

Holger
Registered User
Posts: 1711
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Re: Force https and www

Post by Holger » Wed Mar 27, 2019 9:38 am

Nice, thank you!
How can I combine that with force https?

User avatar
janus_zonstraal
Registered User
Posts: 3192
Joined: Sat Aug 30, 2014 1:30 pm

Re: Force https and www

Post by janus_zonstraal » Wed Mar 27, 2019 9:41 am

RewriteRule ^(.*)$ https
It is forcing to https
Sorry! My English is bat ;) !!!

Holger
Registered User
Posts: 1711
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Re: Force https and www

Post by Holger » Wed Mar 27, 2019 9:49 am

Ahhh, my bad!

User avatar
EA117
Registered User
Posts: 533
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Force https and www

Post by EA117 » Wed Mar 27, 2019 11:46 am

janus_zonstraal wrote:
Wed Mar 27, 2019 9:41 am
RewriteRule ^(.*)$ https
It is forcing to https
It does force HTTPS, but only when the rewrite condition matches. Meaning "http://www.livemembersonly.com" would not become forced to HTTPS, because that URL didn't need to be rewritten to add the "www." subdomain.

I expect that "combine both the www re-write and the HTTPS re-write" into a single rule would look like this:

Code: Select all

RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]

Holger
Registered User
Posts: 1711
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Re: Force https and www

Post by Holger » Wed Mar 27, 2019 12:00 pm

Nice!

User avatar
P_I
Registered User
Posts: 919
Joined: Tue Mar 01, 2011 8:35 pm
Location: Calgary
Contact:

Re: Force https and www

Post by P_I » Wed Mar 27, 2019 12:48 pm

FWIW, in the past I've used htaccess Tester - madewithlove to test changes to .htaccess configuration.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams

User avatar
Lumpy Burgertushie
Registered User
Posts: 66147
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Force https and www

Post by Lumpy Burgertushie » Sun Apr 21, 2019 3:21 pm

I am curious, why would you want to force www? most people are going the other way these days.

www is out of date and not needed any longer.

it is a holdover from the old days when webs sites were hosted on a separate machine and had to have the incoming calls redirected to that actual machine. the same was true for ftp and email etc.

now days that is all done via server software and web pages, ftp and email can all be on the same machine etc.

about the only places you will see where www is required is on some government servers that are still that far out of date.

as far as search engines, they no longer look at www as a subdomain so they don't care about it either.

luck,
robert
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

Holger
Registered User
Posts: 1711
Joined: Tue Mar 12, 2002 3:54 pm
Location: Hannover

Re: Force https and www

Post by Holger » Sun Apr 21, 2019 3:47 pm

I am oldschool Lumpy. For me an URL feels incomplete without www. I dont ”like” URLs without www.

User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 3120
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Force https and www

Post by thecoalman » Sun Apr 21, 2019 7:10 pm

Quick tip, don't use R=301 initially. Browsers, search engines, etc. will cache the response. This can cause problems for testing and other issues that should be obvious. Once you have tested and are satisfied the redirect(s) are working properly then add it.

Post Reply

Return to “[3.2.x] Support Forum”