[Tip] Forcing with or without www. in URL

Status
Not open for further replies.

Floris

I'm just me :) Hi.
Staff member
Jan 1, 2001
60,101
1,425
930
47
Netherlands
mrfloris.com
Think twice before running your site. Do you want to have the www. part included, or not?

Force remove www. from url:
Code:
RewriteCond %{HTTP_HOST} ^www\.xenfans\.com
RewriteRule (.*) http://xenfans.com/$1 [R=301,L]

Force www. to the url:
Code:
RewriteCond %{HTTP_HOST} ^xenfans\.com
RewriteRule (.*) http://www.xenfans.com/$1 [R=301,L]

Add either of the above code to your .htaccess file - inside the xenforo block, just after:
Code:
RewriteEngine On
 
  • Like
Reactions: 3 people

Floris

I'm just me :) Hi.
Staff member
Jan 1, 2001
60,101
1,425
930
47
Netherlands
mrfloris.com
It's really personal preference...

Yes, but highly motivated no-www.org :D

Personally I think it looks cluttered, we type in the browser: xenfans.com
So http and www is obsolete in my book.

I've gone ahead a few years ago by deciding to force remove www. prefix from the domains I run.
And perm 301 redirect all my alias domains to the main domain.
I also decided on force removing the index.php (which xenforo does basically if you use friendly urls)

so

http://www.wetalknation.net/index.php

ends up as

http://wetalknation.net/
 

Mikey

:mikey:
Staff member
Jan 26, 2008
17,836
692
510
33
Disunited Queendom
mikeylicio.us
Chrome now removes http:// from the visible url anyway, and fades out www. and everything after the tld so that the only thing in the url bar which is 'black' font is the site address itself.
 

Floris

I'm just me :) Hi.
Staff member
Jan 1, 2001
60,101
1,425
930
47
Netherlands
mrfloris.com
Chrome now removes http:// from the visible url anyway, and fades out www. and everything after the tld so that the only thing in the url bar which is 'black' font is the site address itself.
quite annoying when you copy paste sites to friends :p
 

imported_Brian

OMG Member
Oct 6, 2010
161
1
225
The Lion City
mrbrian.me
On a side note: If you run a sizable site, remember that cookies served from .domain.com are sent with EVERY SINGLE HTTP REQUEST. If you have a large number of subdomains, you may want to consider redirect all main traffic TO www so that you can serve, say, images, from another subdomain without all the cookie traffic.
 

Cezz

OMG Member
Sep 24, 2010
581
48
255
36
United Kingdom
Hey floris,

Thank you for the tip, I personally use some reversed logic and say

Code:
RewriteCond %{HTTP_HOST} !www\.xenfans\.com
RewriteRule (.*) http://www.xenfans.com/$1 [R=301,L]

This way it will catch all possible differences, be it parked domains' or additional subdomain's etc...
 
  • Like
Reactions: 2 people
Status
Not open for further replies.