# Rewrite rule

**URL:** <https://www.ruby-forum.com/t/rewrite-rule/137450>\
**Category:** Rails\
**Created:** [May 13, 2008, 8:43am UTC](https://www.ruby-forum.com/t/rewrite-rule/137450 "2008-05-13T08:43:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ripan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df705f/32.png) [@ripan](https://www.ruby-forum.com/u/ripan)\
**Post date:** [May 13, 2008, 8:43am UTC](https://www.ruby-forum.com/t/rewrite-rule/137450/1 "2008-05-13T08:43:27Z")

</div>

please design a rule such that any .php request is blocked by apache  
as File Not Found 404 and is not forwarded to mongrel.

ie instead of this error  
ActionController::RoutingError (no route found to match “/view.php”  
with {:method=\>:get}):

I should get …

File Not Found 404

ripan

---

<div class="post-metadata">

**Author:** ![ripan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df705f/32.png) [@ripan](https://www.ruby-forum.com/u/ripan)\
**Post date:** [May 13, 2008, 6:10pm UTC](https://www.ruby-forum.com/t/rewrite-rule/137450/2 "2008-05-13T18:10:41Z")

</div>

I have something like this in my apache vhost:

RewriteEngine On  
RewriteRule .php$ /404.html [R=404,L]

(Actually, I have a bunch of specific rewrites that move people to our  
old php site’s URLs to the new rails site’s corresponding URL, so  
please forgive me if my regexp is not quite right.)

-Kyle

---

<div class="post-metadata">

**Author:** ![ripan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df705f/32.png) [@ripan](https://www.ruby-forum.com/u/ripan)\
**Post date:** [May 14, 2008, 6:49am UTC](https://www.ruby-forum.com/t/rewrite-rule/137450/3 "2008-05-14T06:49:02Z")

</div>

Hi …thanx 4 replying,

RewriteRule ^/?(.\*.php)$ %{DOCUMENT\_ROOT}/public/404.html

rewrite rule is working for me

Ripan
