1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to manipulate .htaccess rewrite rule with querystring

Discussion in 'Apache' started by rajnikant, Feb 7, 2007.

  1. #1
    Hello,

    I have been learning .htaccess since last couple of weeks.

    Below is my requirement:

    Recently, my site has been shifted to new server i.e. linux server.
    It was hosted on the window server in the past and few affiliates are joined with it.

    I have installed a different affiliate programme on the new server than it was on the old server

    As the affiliate programme on old server and new server are different now, the referral link would be different.

    One of our affiliates saying, I dont wanna to chage my link referring your site, because it has placed on so many sites and if you change it then I have to place the new link on all the sites where this link was kept.

    So to fulfill the requirement of this affiliate , I want to write a rule in .htaccess of new server which will find if the request coming from old link then redirect to new link with querystring.

    for example,
    this was old link for tht affiliate - http://www.domain.com/xyz.cfm?page=drug&affiliate=30303916

    and the new link for him is now - http://www.domain.com/drugname.html?a_aid=fbb92383&a_bid=ad15c1ee

    This is how if a request comes from old link , .htaccess file should redirect it to the new link with the querystring.

    I tried with the following rule , but it didn't work out.

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^xyz.cfm?page=drug&affiliate=30303916$
    Redirect /drugname.html?a_aid=fbb92383&a_bid=ad15c1ee

    Can anyone pls give me correct rewrite rule for this ?

    Thanking you.
     
    rajnikant, Feb 7, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's along the right lines but query string only contains the string after the ? in the URL.

    RewriteCond %{QUERY_STRING} ^page=drug&affiliate=30303916$
    RewriteRule xyz.cfm drugname.html?a_aid=fbb92383&a_bid=ad15c1ee [R=301]
    Code (markup):
     
    rodney88, Feb 7, 2007 IP
  3. rajnikant

    rajnikant Peon

    Messages:
    18
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Wow great, It's solved. but it still needs to put / before drugname.html?a...

    Anyways, thank you very much.
     
    rajnikant, Feb 7, 2007 IP