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


RewriteCond %{HTTP_HOST} !^ [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…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs