Article written

  • on 20.05.2009
  • at 08:48 AM
  • by arkin

Force Users to use www.yourdomain.com not yourdomain.com. 0

May20

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.

subscribe to comments RSS

There are no comments for this post

Please, feel free to post your own comment

* these are required fields

arkinEx Codex is powered by WordPress and FREEmium Theme.
developed by Dariusz Siedlecki and brought to you by FreebiesDock.com