Redirect non www directory to www directory

hi

i want non-www url redirect to www url

domain.com/folder/

to get redirect to

www.domain.com/folder/

if i use below code

RewriteCond %{HTTP_HOST} ^example.com/folder/ [nocase]
RewriteRule ^(.*) http://www.example.com/folder/$1 [last,redirect=301]

Then the url gets redirect to

www.domain.com

and misses the folder path.

How can i add the folder path to the above code.

Thanks
Vineet

vin,

Very simply, the {HTTP_HOST} does not contain anything other than the domain name requested (NOT folder). If you want to match folder, do it in the RewriteRule or with an additional RewriteCond statement.

Regards,

DK

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.