Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Are you using chrome? Have you checked in other browsers? – Anagio Aug 22 '12 at 22:37
Its the same on both ff and chrome. – user17901 Aug 22 '12 at 22:44
Do you have RewriteEngine On set? – Anagio Aug 22 '12 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 Aug 22 '12 at 22:52
Got it, my retarded host edited the file after me 0.o Anyway, thanks. – user17901 Aug 22 '12 at 22:58

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.

share|improve this answer
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 Aug 23 '12 at 14:09
@SnakeByte - I'm sorry to hear that, but glad you have it working now. – ionFish Aug 23 '12 at 14:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.