# Redirecting .php / .aspx requests?

**URL:** <https://www.ruby-forum.com/t/redirecting-php-aspx-requests/150330>\
**Category:** Rails\
**Created:** [October 7, 2008, 1:22pm UTC](https://www.ruby-forum.com/t/redirecting-php-aspx-requests/150330 "2008-10-07T13:22:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [October 7, 2008, 1:22pm UTC](https://www.ruby-forum.com/t/redirecting-php-aspx-requests/150330/1 "2008-10-07T13:22:53Z")

</div>

I’m rebuilding my site and with google i’m getting a load of requests  
for .php or .aspx files which the previous site was built on.

Is there any way of redirecting these [www.mysite.com/index.aspx](http://www.mysite.com/index.aspx) requests  
to the /index action via the routes, maybe a wildcard, so google  
sitemaps doesn’t list those old links as errors?

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [October 7, 2008, 5:14pm UTC](https://www.ruby-forum.com/t/redirecting-php-aspx-requests/150330/2 "2008-10-07T17:14:43Z")

</div>

On 7 Oct 2008, at 12:22, John G. wrote:

> I’m rebuilding my site and with google i’m getting a load of requests  
> for .php or .aspx files which the previous site was built on.
> 
> Is there any way of redirecting these [www.mysite.com/index.aspx](http://www.mysite.com/index.aspx)  
> requests  
> to the /index action via the routes, maybe a wildcard, so google  
> sitemaps doesn’t list those old links as errors?

You could do this via a mod\_rewrite rule, or if you just want rails to  
accept those urls, you should be able to do that by adding a pseudo  
mime type (in the same say that you can do to yourapp/orders.xml and  
get an xml representation, you should be able to add pseudo types for  
php and aspx that just behaved the same as the html ones)

Fred

---

<div class="post-metadata">

**Author:** ![softf5ajivanet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@softf5ajivanet](https://www.ruby-forum.com/u/softf5ajivanet)\
**Post date:** [October 7, 2008, 6:11pm UTC](https://www.ruby-forum.com/t/redirecting-php-aspx-requests/150330/3 "2008-10-07T18:11:10Z")

</div>

ok, so if i add a type for php,

Mime::Type.register “application/x-httpd-php”, :php

and then something in my route.rb to redirect any .php calls to the  
appropriate place i should be ok?
