asherwolf
Member
Posted 1 year ago #
I have finished a wordpress installation and a client brought up something very interesting about the www prefix in the address. We had sidebar login plugin which shows you if you are logged in. If he logs in under http://www.sitename.com he becomes logged in. However, if then accesses sitename.com without the WWW he becomes logged out.
On top of that, I am running Bad Behavior plugin, and when he accesses the site without the WWW prefix and tries to log in with the sidebar login, it catches it as a possibly spam access because the form doesn't match the url.
Anyone else have this problem? Specifically, is there any way to get WordPress to store cookies for both sitename.com and http://www.sitename.com at the least?
Thanks,
Asher
asherwolf
Member
Posted 1 year ago #
UPDATE: I just got Bad Behavior to ignore the sidebar login if it's from a 'different URL'. However, the cookies are still awry when not using www prefix. Thanks again,
Asher
A simple workaround might be to simply force the site to add the www if loaded without. Check your host for the correct .htaccess syntax for your specific server, but this often works, assuming you're on a Linux server with Apache:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
Please be careful when editing your .htaccess file and make a backup of the original file. Use a plain-text editor and upload in ASCII format only. Make sure you first download the live .htaccess so you don't overwrite anything.
asherwolf
Member
Posted 1 year ago #
I actually did that. I placed:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.sitename\.com [NC]
RewriteRule ^(.*)$ http://www.sitename.com/$1 [R=301,L]
</IfModule>
Above # BEGIN wordpress
I'm just worried that this will effect web-crawlers and -spiders. Things I really want. Does anybody know if this is a legitimate concern? I haven't been able to find a suitable explanation out on the internet for me.
Thanks for the help!
Asher
Ideally, you don't want the site to be available on both www and non-www versions. Pick one and stick with it.
Most people prefer non-www nowadays, really. It's shorter, and "www" is kinda redundant to begin with.
Doing the non-www to www redirect is actually good for SEO, because there is no chance of a duplicate-content penalty, since search engines will now spider only one URL per page.
asherwolf
Member
Posted 1 year ago #
Thanks for the input guys. I'll worry less about it now.
Thanks again,
Asher