[Tip] Forcing with or without www. in URL

Status
Not open for further replies.

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,100
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
 

kuyenmotdivad

OMG Member
Joined
Oct 24, 2010
Messages
184
I'd use the one without the www as a lot of people dont type in www and it automatically goes to the non www site
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,100
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
Joined
Jan 26, 2008
Messages
17,836
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
Joined
Jan 1, 2001
Messages
60,100
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
Joined
Oct 6, 2010
Messages
161
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
Joined
Sep 24, 2010
Messages
581
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...
 

merk51

OMG Member
Joined
Jul 16, 2008
Messages
46
I'm with those who prefer it without www - thanks for these re-writes Floris :) Anyway (unless I have overlooked it) to get the index.php taken out of it as well?
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,100
Turn on friendly urls in xenforo, and it will rewrite it already.
 
Status
Not open for further replies.
Top