SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Redirect old asp links on concerned sister sites to current php page

    Hi everyone,

    I am new to htaccess redirects and so need a little help.

    I have a new site running on php and i have to redirect all links that point to asp to route to php page. Example.. links to

    Code:
    http://www.mysite.com/tour.asp?id=1234
    should go to

    Code:
    http://www.mysite.com/tour.php?tourid=1234
    Let me mention here though its very obvious that 1234 is dynamic here and will change.

    How can i accomplish this using htaccess? I am using the following server config
    Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_bwlimited/1.4 PHP/5.3.16

    Thanks

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    lw,

    Welcome to SitePoint!

    If the value of id and tourid are identical, the answer is simple:

    Code:
    # in .htaccess in mysite.com's DocumentRoot
    
    # capture the value of id (for tourid)
    RewriteCond %{QUERY_STRING} ^id=([0-9]+)
    # redirect .asp request to .php with tourid
    RewriteRule ^([a-z]+)\.asp$ $1.php?tourid=%1 [R=3-1,L]
    While the comments should be sufficient explanation, you may need more. If you do, you might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members (all but one) and should help you, too.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •