# URL rewrite to other domain for all local requests

**URL:** <https://www.ruby-forum.com/t/url-rewrite-to-other-domain-for-all-local-requests/158444>\
**Category:** Rails\
**Created:** [January 23, 2009, 12:41pm UTC](https://www.ruby-forum.com/t/url-rewrite-to-other-domain-for-all-local-requests/158444 "2009-01-23T12:41:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackflash](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/dfb087/32.png) [@blackflash](https://www.ruby-forum.com/u/blackflash)\
**Post date:** [January 23, 2009, 12:41pm UTC](https://www.ruby-forum.com/t/url-rewrite-to-other-domain-for-all-local-requests/158444/1 "2009-01-23T12:41:43Z")

</div>

Is it possible to rewrite all URL’s (routes) inside a rails app for  
all local request to link to other domain if RAILS\_ENV=test.

If I open the application at www.domain\_for\_private\_site.com, then all  
forms, links, etc, should make requests on  
www.domain\_for\_public\_site.com?

For example, if I make a get request on  
http://www.domain\_for\_private\_site.com/blogs/new,  
that contains something like:

and it should be changed with this:

same for all other URL’s.

It should be done in Rails, not in Apache server or similar.
