I know that following code is required for redirecting a non www link to www link: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.domain\.com RewriteRule (.*) http://www.domain.com/$1 [L,R=301] Code (markup): And I have included it too on the main site's .htaccess. But the problem is that I have a gallery in a subfolder which works on a different script with a different .htaccess. If I access http://domain.com/gallery/ it does not get redirected to www version. I tried including the above code into .htaccess in gallery folder but then it redirects the gallery to site's homepage. Pls suggest a fix so that non www gallery redirects to gallery having www link.