site redirection

Hi there,

I use this in my .htaccess for redirect URL mysite.cr to www.mysite.cr.
It redirects fine.

...
...
...
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.cr [NC]
RewriteRule ^(.*)$ http://www.mysite.cr/$1 [L,R=301]

But the first URL(the one that does not has www) stays without www
even when it redircets properly. What i am trying to do is that no
matter what URL somebody use( www.mysite.cr or mysite.cr), i want the
final URL always to have www at the beginig.

Any idea?

Cheers

No need to use mod_rewrite

RedirectMatch 301 ^/(.*) http://…/$1

hi,

ok i tryed with

RedirectMatch 301 ^/(.*) http://…/$1

and it does not worked, in fact this solution loads the site without
any css.

I am using the htaccess located in the public folder, do i have to
configure something else for doing this???

Cheers

another thing i am using passenger for my app, maybe passenger do not
like .htaccess in public directory...no idea???

even if i delete the htaccess(some say that passenger dont like
htaccess) does not work

I would use mod_rewrite and not mod_alias (RedirectMatch) for this
task, and here is a example that will make sure you stay with www.

# Force www.cadechristian.com
RewriteCond %{HTTP_HOST} !^www\.cadechristian\.com [NC]
RewriteRule ^/(.*) http://www.cadechristian.com/$1 [L,R=301]

This will always add the proper url with the leading www.

in fact my first attempt was exactly what heimdull suggest. But it
does not worked. I think this has to be somthing related with
passenger....any other ideas?

i have created a"test" folder inside my application publuc folder.
Inside test foler i have created one .htaccess file that redirects to
www.yahoo.com when i point my browser to it, redirects me to yahoo.
But this htacces does not work inside my app's public folder, it just
do not do the redirect......