Andreasa2010
asked on
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...
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
RedirectMatch ^/(.*)\.asp$ /dept/$1.php