Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hi all, today I noticed that when my site URL is written with the www. before the domain name the content inside the tags
Code: Select all
<cms:if k_user_access_level ge '7' > </cms:if>

is not shown but when I write only "domainname.com" without www. at the beginning then the content is visible... Does anybody knows what can be causing this issue?
Hi,

That is because 'www.yoursite.com' and 'yoursite.com' are considered two different sites and so the authentication cookie for one domain becomes invalid for the other.

Allowing both 'www' and 'non www' URLs leading to the same page is considered bad for SEO for this very reason as Google considers the two URL as separate.

To rectify this you can use .htaccess to enforce that anyone accessing a non-www URL is always redirected to the one with www.

Placing the following directives in the .htaccess file in your site's root should do the trick -
Code: Select all
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

If you are using Couch's prettyURLs, the .htaccess file generated by it already contains the directives mentioned above but are commented out. You can uncomment them (by removing the leading #).

Hope this helps.
Thanks kk that solved it
on this same subject I tend to prefer to drop the www prefix and let the site be known by that version of the URL. I have used this in the .htaccess file - can I pass it by you to make sure it is a sound method - thanks!
Code: Select all
# Redirect to domain without www.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* http://%1%{REQUEST_URI} [R=301,L]
# Same for HTTPS:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]
@potato, the important thing is to prevent the same page from being accessed via two URLs. Your method does just that so it is a perfectly fine approach.
5 posts Page 1 of 1