htaccess: Redirect with virtual subdomains

Please help me! I have moved my entire site from ASP to PHP and need a 301 Redirect that will send the old asp-pages to the new php-pages (with the same name - except from the php-extension):

http://www.mysite.com/test.asp --> http://www.mysite.com/test.php

And default.asp should go to index.php:

http://www.mysite.com/folder/default.asp --> http://www.mysite.com/folder/index.php

So fare this works fine:

RedirectMatch permanent (.*)default\.asp$ http://www.mydomain.com$1index.php
RedirectMatch permanent (.*)\.asp$ http://www.mydomain.com$1.php

BUT, it also needs to work with virtual subdomains:

http://whatever.mysite.com/folder/test.asp --> http://whatever.mysite.com/folder/test.php

This is as fare as I got:

RewriteCond %{HTTP_HOST} ^([^\.]+)\.mydomain\.com$ [NC]
RedirectMatch permanent (.*)default\.asp$ http://%1.mydomain.com$1index.php
RedirectMatch permanent (.*)\.asp$ http://%1.mydomain.com$1.php

But is is not working...
Andreasa2010Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dushyant SharmaCommented:
try this

RedirectMatch ^/(.*)\.asp$ /dept/$1.php
Dushyant SharmaCommented:
oops!! dept is part of my redirect please remove that

RedirectMatch ^/(.*)\.asp$ /$1.php

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andreasa2010Author Commented:
Thanks!

I actually - with a litle help - got this to work:

RewriteEngine On
RewriteRule (.*)default\.asp$ http://%{HTTP_HOST}/$1index.php [L,R=301]
RewriteRule (.*)\.asp$ http://%{HTTP_HOST}/$1.php [L,R=301]

But you get the points!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.