Force Users to use www.yourdomain.com not yourdomain.com.
If your having problems with cookies, and incoming links sometimes varying between www.example.com and example.com, which doesn’t help SEO.
Use this quick fix to solve your problem.
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [QSA,L,R=301]
It will forward your users keeping their path and query string.
Example: http://test.com/page.html?affiliate_id=1 is redirected to http://www.test.com/page.html?affiliate_id=1
The 301 code that is also sent ensures search engines understand that this redirect is permanent which helps your site keep and maximize its SEO ranking.
I hope this helps, as always, ask your questions in the comments.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments
No comments yet.
Leave a comment