Page 1 of 2
Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 8:29 am
by ross
As others have mentioned, this can affect logging in issues, SEO, etc., so best to get this sorted quickly. You need an .htaccess file in the root of your domain, modrewrite enabled, and this text in the file:
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.lifein19x19\.com [NC]
RewriteCond %{HTTP_HOST} !=""
RewriteRule ^(.*)$ http://www.lifein19x19.com/$1 [L,R=301]
This will ensure that if somebody leaves off the "www", or visits the site using another domain name that points here, the URL will get canonicalized to its proper, "one true form". There can be only one!
Re: Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 8:40 am
by ChradH
ross wrote:This will ensure that if somebody leaves off the "www", or visits the site using another domain name that points here, the URL will get canonicalized to its proper, "one true form". There can be only one!
One question: Are you suggesting to add "www." to every url? How about the other way round?
I find this "www." prefix highly redundant and really
hate sites that only work when it's added. Please, let's keep it short and simple.
Re: Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 8:42 am
by Chew Terr
He/they are making it so that you do NOT have to add the www. Fear not =)
Re: Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 8:45 am
by ross
ChradH wrote:One question: Are you suggesting to add "www." to every url? How about the other way round?
I find this "www." prefix highly redundant and really hate sites that only work when it's added. Please, let's keep it short and simple.
The site will
work either way, it's just a matter of how it shows up in the URL bar (and how search engines and cookies treat it, etc). I'm agnostic as to which way is better, I just think it should be standardized. You probably don't even notice the sites that put it on automatically for you, only the misconfigured sites that don't allow the "www." at all.
Re: Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 8:57 am
by fwiffo
I don't care which version we use, we just need to pick one. I've actually been having DNS issues with the www version, weirdly enough, so I guess I favor the shorter version...
Re: Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 8:58 am
by ChradH
ross wrote:The site will work either way, it's just a matter of how it shows up in the URL bar (and how search engines and cookies treat it, etc). I'm agnostic as to which way is better, I just think it should be standardized. You probably don't even notice the sites that put it on automatically for you, only the misconfigured sites that don't allow the "www." at all.
I'm with you there, having one canonical address is a must. And though I
might survive having "www." pasted in front of the sleek and elegant lifein19x19 I just typed into the address bar, I'd like it better without.
So it's the misconfigured sites forcing me to add the "www." which drive me mad.
*twitch*
Mad... maaad... MAAAD.... !!!

Re: Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 9:09 am
by kirkmc
fwiffo wrote:I don't care which version we use, we just need to pick one. I've actually been having DNS issues with the www version, weirdly enough, so I guess I favor the shorter version...
Hmm, I don't see that we "need" to pick one; both work, and it's a pretty standard "hack" for websites. I do it on all mine. If there's a DNS issue, that'd be somewhat odd - no one else has posted about DNS issues for the URL.
Re: Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 9:17 am
by ross
kirkmc wrote:Hmm, I don't see that we "need" to pick one; both work, and it's a pretty standard "hack" for websites. I do it on all mine. If there's a DNS issue, that'd be somewhat odd - no one else has posted about DNS issues for the URL.
By "pick one" we mean standardize on one to 301-redirect the others to (for aforementioned SEO, cookie, etc. issues).
Re: Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 9:17 am
by xed_over
kirkmc wrote:Hmm, I don't see that we "need" to pick one; both work,
Yes we do, Ross is right.
But not "we" (public), "we" (site owners/admins). It will be practically invisible to we-public.
Because of tracking cookies and such, there needs to be only one site. All others should redirect to it.
Re: Canonical URL via modrewrite
Posted: Fri Apr 23, 2010 10:29 am
by unkx80
Yes, better to just redirect the www. version to the version without www. (or the other way round). Then people and search engines will see and bookmark only one version.
Re: Canonical URL via modrewrite
Posted: Tue Apr 27, 2010 10:06 am
by xed_over
people are still having
trouble with this issue. what's the status?
Re: Canonical URL via modrewrite
Posted: Tue Apr 27, 2010 11:46 am
by Jordus
We think we have found the problem. We will try fixing soon during a period of low traffic.
Re: Canonical URL via modrewrite
Posted: Tue Apr 27, 2010 4:14 pm
by ross
Jordus wrote:We think we have found the problem. We will try fixing soon during a period of low traffic.
Ummmm... did you find that you need to have a canonical URL, and you're going to use modrewrite to do a 301 redirect?

Or are you attempting some other solution?
Re: Canonical URL via modrewrite
Posted: Tue Apr 27, 2010 4:17 pm
by Jordus
ross wrote:Jordus wrote:We think we have found the problem. We will try fixing soon during a period of low traffic.
Ummmm... did you find that you need to have a canonical URL, and you're going to use modrewrite to do a 301 redirect?

Or are you attempting some other solution?
Originally I came across this on a phpbb3 site:
I would suggest you set your cookie domain in phpbb and all products to this
.domain.com
reason being if someone clicks some link and there is not a www in it or say they login in phpbb without the www the cookie is not recognized on www or vice versa with no www depending on how they login. with a cookie domain of .domain.com your users will be logged in continuously nomatter the subdomain.
Also if logging in through PHPBB make sure they click the remember me button to create a cookie since our products work with cookies not sessions.
\
However fwiffo pointed out the mod rewrite should be done too for other reasons. So we are going to try the modrewrite first.
Re: Canonical URL via modrewrite
Posted: Wed Apr 28, 2010 8:25 pm
by Jordus
Added the mod rewrite and changed cookie info. works for me. Anybody else?
Hint: be sure to clear cookies and restart browser first.