site redirection

Hi there,

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

RewriteEngine On
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$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( or, i want the
final URL always to have www at the beginig.

Any idea?


No need to use mod_rewrite

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


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???


another thing i am using passenger for my app, maybe passenger do not
like .htaccess in public 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
RewriteCond %{HTTP_HOST} !^www\.cadechristian\.com [NC]
RewriteRule ^/(.*)$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 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......