Htaccess redirect folder without www to with www

Hello,

How can I redirect http://mysite.com/admin to http://www.mysite.com/admin using htaccess?

Thanks.

pd,

Look at the mod_rewrite tutorial linked in my signature as the code is in there (as well as the sticky at the top of this forum).

Regards,

DK

I tried
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC]
RewriteRule .? http://www.mysite.com%{REQUEST_URI} [R=301,L]

This should be written in htaccess in the root directory … right? However, When I try it for http://mysite.com/admin it doesn’t redirect to http://www.mysite.com/admin … Instead it redirects to www.mysite.com/401.shtml 404 error found

Am I missing something?

Thanks.

pd,

Does /admin exist? Do you have a redirection set for it that’s not working? It’s making the redirection to www but can’t find the requested script.

Regards,

DK

Yea, sure there is…

But Do I have to change anything here?
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC]
RewriteRule .? http://www.mysite.com%{REQUEST_URI} [R=301,L]

or should I add the admin somewhere in the rule?

pd,

No, that’s correct.

Regards,

DK