Forum Moderators: phranque

Message Too Old, No Replies

How to make https always show when you have a SSL

If the full URL is typed it works

         

ztaco

1:50 am on Sep 24, 2017 (gmt 0)

5+ Year Member Top Contributors Of The Month



I want my site to show https://www.example.com, no matter how typed in URL.
Can
example.com,
www.example.com,
http://example.com,
all to go to https://www.example.com

lucy24

3:05 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



At the risk of sounding like That Other Forum ...

... I could swear this identical question has been asked within the last two weeks. (Can anyone remember where it was? It goes without saying that I can't find it.) It's a combination of

-- DNS settings
-- canonicalization redirect
-- browser URL display

phranque

3:50 am on Sep 24, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you do this by specifying the canonical protocol and hostname (https://www.example.com) in the target of all external redirects (RewriteRule with [R] option flag specified) and by appending a general hostname canonicalization redirect after any and all specific external redirects.

the general hostname canonicalization redirect typically looks something like this:
# if the requested protocol is not HTTPS or
# if the provided Host header value (if any) is not exactly the canonical hostname (or null)
# externally redirect any such noncanonical protocol or hostname requests using a 301 status code to the same requested path (and possibly query string) on the canonical protocol and hostname
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]


if you want to drop any potential query strings from the redirect urls use this RewrtiteRule instead:
RewriteRule (.*) https://www.example.com/$1? [R=301,L]

whitespace

9:26 pm on Sep 24, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



@lucy24 This one...?
[webmasterworld.com...]

lucy24

11:58 pm on Sep 24, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yeah, probably. But there was also one where we got sidetracked into explaining that we have no control over what the browser's address bar chooses to display.