Forum Moderators: phranque

Message Too Old, No Replies

How do you do a hostname canonicalization redirect?

         

Dexie

6:01 pm on Mar 25, 2015 (gmt 0)

10+ Year Member



How do you change the .htaccess file, so that if people enter the whole website address http//.www.example.com or http.example.com or example.com - in other words, all the usual variations, always go to www.example.com - without any http, etc, also regardless if they enter the address in lower case or upper case please?

phranque

7:02 pm on Mar 25, 2015 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



change it from what?
it depends on the mod_rewrite and mod_alias directives you currently have in your .htaccess and httpd.conf files.

lucy24

7:35 pm on Mar 25, 2015 (gmt 0)

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



You're looking for the domain-name-canonicalization redirect. This question has been asked at least once a week for all the years this site has been in existence, so a quick search constrained to the /apache/ subforum should bring up hundreds of examples.

I'm worried, though, that you've misunderstood something. There is nothing you can do to change the display of "http(s)://" because that decision is made by the browser. If it happens that some of your content is reachable by both http and https, that's a separate redirect. Same RewriteRule, additional RewriteCond.

phranque

7:44 pm on Mar 25, 2015 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I think Dexie is referring to the http.example.com subdomain, not the HTTP: protocol.

lucy24

10:11 pm on Mar 25, 2015 (gmt 0)

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



I sure hope so ;)

But as long as you're here, feel like editing the thread title to, er, something more useful?

Dexie

6:29 am on Mar 26, 2015 (gmt 0)

10+ Year Member



No probs, just found the answer elsewhere! By the way, if you look at the website address of this forum, you'll see no mention of http!

lucy24

7:16 am on Mar 26, 2015 (gmt 0)

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



if you look at the website address of this forum, you'll see no mention of http

I think it would be a big help and would clear up a lot of confusion if you would explain exactly what you mean by this :(