Topic: Redirects using a regex?

I need to create a redirect so whenever someone goes to anything beneath a certain folder (e.g. www.domain.com/folder/ANYTHING) they will be redirected to www.someotherdomain.com/folder/ANYTHING.

I know how to do the redirect part but not sure how to use a regex for whatever is entered after the first directory. Any help would be greatly appreciated.

Re: Redirects using a regex?

There is a good article about that kind of thing here. I imagine you'd want something like:

redirect_to_url path.gsub(%r{domain.com}, 'someotherdomain.com'), true if path.match %r{/folder/}

Alex

Re: Redirects using a regex?

This sounds like a job for mod_rewrite if you're using apache

Railscasts - Free Ruby on Rails Screencasts