I read a ton of posts and pages trying to figure this out. I mainly work. I have a .htaccess file setup and I'm trying to redirect (301) any page on my site from non-www to www.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
It seems to work from the base url. However, it does not redirect to sub pages.
It works:
example.com → www.example.com
This does not work:
example.com/foo.html → www.example.com/foo.html
Any help would be greatly appreciated
Randy source
share