# Query String in routes

**URL:** <https://www.ruby-forum.com/t/query-string-in-routes/96423>\
**Category:** Rails\
**Created:** [January 24, 2006, 4:10am UTC](https://www.ruby-forum.com/t/query-string-in-routes/96423 "2006-01-24T04:10:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_ASLambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f08c70/32.png) [@Jon\_ASLambert](https://www.ruby-forum.com/u/Jon_ASLambert)\
**Post date:** [January 24, 2006, 4:10am UTC](https://www.ruby-forum.com/t/query-string-in-routes/96423/1 "2006-01-24T04:10:11Z")

</div>

Is there any way to access the query string full request uri in  
routes.rb?

I’d like to route requests for those going after my old application urls  
to  
my new rails application urls.

The old app used  
/wiki.cgi?PageName  
The rails app uses  
/wiki/show/PageName

Like…  
map.connect ‘wiki.cgi’, :controller =\> “wiki”, :action =\> “show”, :id  
=\>  
ENV[‘QUERY\_STRING’]

ENV doesn’t contain any CGI bits at all at the point routes.rb is  
called.

env is invalid  
request is invalid  
params is invalid

What variables ARE valid at this point and do any of them contain what I  
want?

No Apache solutions please.

Thanks.

–  
J. Lambert

---

<div class="post-metadata">

**Author:** ![Jon\_ASLambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f08c70/32.png) [@Jon\_ASLambert](https://www.ruby-forum.com/u/Jon_ASLambert)\
**Post date:** [January 24, 2006, 8:13am UTC](https://www.ruby-forum.com/t/query-string-in-routes/96423/2 "2006-01-24T08:13:05Z")

</div>

Jon A. Lambert wrote:

> Is there any way to access the query string full request uri in  
> routes.rb?
> 
> I’d like to route requests for those going after my old application urls  
> to  
> my new rails application urls.
> 
> The old app used  
> /wiki.cgi?PageName  
> The rails app uses  
> /wiki/show/PageName
> 
> Like…  
> map.connect ‘wiki.cgi’, :controller =\> “wiki”, :action =\> “show”, :id

> J. Lambert

map.connect ‘wiki.cgi?:id’, :controller =\> “wiki”, :action =\> “show”,  
:id =\> :id

The above should work, but it will still show wiki.cgi?PageName in the  
browser. You could add an action to your wiki controller to redirect:  
def redirect  
redirect\_to :controller =\> “wiki”, :action =\> “show”, :id =\>  
params[:id]  
end

The the route would be:

map.connect ‘wiki.cgi?:id’, :controller =\> “wiki”, :action =\>  
“redirect”, :id =\> :id
