Welcome to WebmasterWorld Guest from 3.85.214.0

Forum Moderators: Ocean10000 & 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

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

New User from US 

Top Contributors Of The Month

joined:Sept 20, 2017
posts:29
votes: 0


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
3:05 am on Sept 24, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15869
votes: 869


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
3:50 am on Sept 24, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11842
votes: 242


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]
9:26 pm on Sept 24, 2017 (gmt 0)

Full Member

Top Contributors Of The Month

joined:Apr 11, 2015
posts: 328
votes: 24


@lucy24 This one...?
[webmasterworld.com...]
11:58 pm on Sept 24, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15869
votes: 869


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.