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.
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):
Wow great, It's solved. but it still needs to put / before drugname.html?a... Anyways, thank you very much.