# Custom routes

**URL:** <https://www.ruby-forum.com/t/custom-routes/67690>\
**Category:** Rails\
**Created:** [September 6, 2006, 2:14am UTC](https://www.ruby-forum.com/t/custom-routes/67690 "2006-09-06T02:14:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hreyaatnh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f17d59/32.png) [@hreyaatnh](https://www.ruby-forum.com/u/hreyaatnh)\
**Post date:** [September 6, 2006, 2:14am UTC](https://www.ruby-forum.com/t/custom-routes/67690/1 "2006-09-06T02:14:01Z")

</div>

I want to display the 404.html page for routes that are not defined in  
my application. So if a visitor tries to visit  
“http:://www.yoursite.com/undefined” instead of “Routing error” they  
will get my 404.html page.

How can this be handled? Is there a way to setup something in routes.rb  
for all routes not defined and/or not controller/action? Thanks…

---

<div class="post-metadata">

**Author:** ![hreyaatnh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f17d59/32.png) [@hreyaatnh](https://www.ruby-forum.com/u/hreyaatnh)\
**Post date:** [September 6, 2006, 2:50am UTC](https://www.ruby-forum.com/t/custom-routes/67690/2 "2006-09-06T02:50:56Z")

</div>

Not sure if this is the best way to go about this, so hopefully  
someone else will comment, but if you put:

map.connect ‘\*anything’, :controller =\> “blah”, :action =\>  
“unknown\_request”

at the end of your routes, it will map anything it doesnt recognize  
to the “unknown\_request” action.

---

<div class="post-metadata">

**Author:** ![hreyaatnh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f17d59/32.png) [@hreyaatnh](https://www.ruby-forum.com/u/hreyaatnh)\
**Post date:** [July 31, 2008, 6:05pm UTC](https://www.ruby-forum.com/t/custom-routes/67690/3 "2008-07-31T18:05:07Z")

</div>

ry an wrote:

> I want to display the 404.html page for routes that are not defined in  
> my application. So if a visitor tries to visit  
> “http:://www.yoursite.com/undefined” instead of “Routing error” they  
> will get my 404.html page.
> 
> How can this be handled? Is there a way to setup something in routes.rb  
> for all routes not defined and/or not controller/action? Thanks…

Hi  
I think you place your application in production environment.  
when routes is not match then it gives 404.html page. so visitor get  
your default error message instead of routing error.

Thanks  
Priyanka P.  
Software Engineer  
Gloscon Solution Pvt. Ltd.
