RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
If I open mysite.com then this redirects me on http://www.mysite.com. This is OK.
But if I open mysite.com/admin then this redirect me on http://www.mysite.com instead of http://www.mysite.com/admin
How can I fix it?
Should do the trick. Use the parentheses
()to match a pattern then a$1backreference to put it back into the new URL.Edit, thinking about it, similarly you could just change the ^ character (the match on clause) to a . in your original pattern which should do the same as above.