On a joomla site, apache, shared hosting, I'm using next .htaccess rule:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

The problem is that the browser's address bar text does not change from example.com to www.example.com. It seems the redirect actually works because all the links on the pages are changed to www. And after clicking on any link from there it always continues to have www added. The problem is the first page (no matter which one) that is loaded using browser's address bar - like example.com or example.com/random-page.

Solved. The redirect actually works.

  • Are you using chrome? Have you checked in other browsers?
    – Anagio
    Commented Aug 22, 2012 at 22:37
  • Its the same on both ff and chrome.
    – user17901
    Commented Aug 22, 2012 at 22:44
  • Do you have RewriteEngine On set?
    – Anagio
    Commented Aug 22, 2012 at 22:45
  • Yes, i have it up in the htacces. I just noticed that inside jommla back-end it never redirects me to www. Could it be from Folowsymlinks? Few weeks ago when i tried to enable "Options +FollowSymLinks" in htacces got 500 error.
    – user17901
    Commented Aug 22, 2012 at 22:52
  • Got it, my retarded host edited the file after me 0.o Anyway, thanks.
    – user17901
    Commented Aug 22, 2012 at 22:58

1 Answer 1


That's the same code I use so I don't think there's anything wrong with that. Maybe the browsers are caching the URL for whatever reason. But it might be another idea to check out http://wwwizer.com (top banner) where you set your naked A-record to that IP, then your A-record for www to your own IP. That eliminates any need for .htaccess rules.

  • Yes this code is working correctly. The issue was that my hosting provider had some issues with Cpanel and i was unable to get to my .htaccess file meanwhile. And during that time they overwrote my .htaccess file by mistake.
    – user17901
    Commented Aug 23, 2012 at 14:09
  • @SnakeByte - I'm sorry to hear that, but glad you have it working now.
    – ionFish
    Commented Aug 23, 2012 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.