301 Redirect .asp to .php & .co.uk to .com

Discussion in 'Apache' started by crazyryan, Nov 28, 2009.

  1. #1
    Hi,

    I'm working on a clients website at the moment, I've just ported it all over from ASP to PHP.

    How can I redirect all requests for a .asp page to .php?

    For example, site.com/about.asp would go to site.com/about.php

    As well as this, the site is also working under .com and .co.uk

    I need to redirect asp to php and any requests for .co.uk to go to .com

    e.g:

    site.co.uk/about.asp would go to site.com/about.php
    site.com/about.asp would go to site.com/about.php
    site.co.uk would go to site.com

    Regards,
    Ryan
     
    crazyryan, Nov 28, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    RewriteEngine On
    RewriteRule ^(.*).asp$ $1.php [R=301,L]

    that should redirect all asp to php

    Edit

    Second part would be

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(.*)yourdomain.co.uk [NC]
    RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]
     
    Bohra, Nov 29, 2009 IP
  3. boymc

    boymc Well-Known Member

    Messages:
    133
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    113
    #3

    Thanks for your guide
     
    boymc, Nov 30, 2009 IP