Forum Moderators: phranque
The urls that I want to redirect are all exactly the same except for the product id which is placed at the end of the affiliate url, so therefore I am trying to make the product id a variable.
Here is an example of how I want to do the redirection.
http://www.mydomain.com/recommend/abc123456
to
http://myaffiliatemerchant.com/click?p=123&a=123456&g=123456
&url=http://subdomain.productmerchant.com/aa/aa.aspx?CID=1234
&LID=123456&DGC=AF&DGSegHS&ACD=^^&AID=¤¤
&DURL=http%253A//subdomain.productmerchant.com/folder/config.aspx
%253Fb%253D%2526c%253Daa%2526bb%253Dabcde1%2526l%253Den%2526oc%253Dabc123456
My htaccess file looks like this:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /RewriteRule ^recommend/(.*)$ http://myaffiliatemerchant.com/click?p=123&a=123456&g=123456
&url=http://subdomain.productmerchant.com/aa/aa.aspx?CID=1234&LID=123456&DGC=AF&DGSegHS
&ACD=^^&AID=¤¤&DURL=http%253A//subdomain.productmerchant.com/folder/config.aspx
%253Fb%253D%2526c%253Daa%2526bb%253Dabcde1%2526l%253Den%2526oc%253D$1 [R=301]
and the link I am using is:
http://www.mydomain.com/recommend/abc123456
However the url is not being redirected properly.
After searching extensively trying to find an answer to this I now assume that there are some characters in the redirected url that are not being parsed in the htaccess.
If anyone suggest a reason why the code above is not working it will be greatly appreciated.
[edited by: jdMorgan at 9:13 pm (utc) on Sep. 23, 2007]
[edit reason] Fixed horizontal scrolling, de-linked. [/edit]
Your substitution URL appears to be this, when it is unescaped:
RewriteRule ^recommend/(.*)$ http://myaffiliatemerchant.com/click?p=123&a=123456&g=123456
&url=http://subdomain.productmerchant.com/aa/aa.aspx?CID=1234&LID=123456&DGC=AF&DGSegHS
&ACD=^^&AID=¤¤&DURL=http://subdomain.productmerchant.com/folder/config.aspx?b=&c=aa
&bb=abcde1&l=en&oc=$1 [R=301]
Jim
[edited by: jdMorgan at 9:13 pm (utc) on Sep. 23, 2007]
http://subdomain.productmerchant.compart of the rewritten url.
I am now trying to go about this a different way as follows:
HTACCESS as below.....
RewriteEngine on
Options +FollowSymlinks
RewriteBase /RewriteRule ^recommend/(.*)$ http://myaffiliatemerchant.com/click?p=123&a=123456&g=123456&url=$1 [R=301]
and the link code I am using is:
http://www.mydomain.com/recommend/http://subdomain.productmerchant.com/aa/aa.aspx?CID=1234&LID=123456&DGC=AF&DGSegHS
&ACD=^^&AID=¤¤&DURL=http://subdomain.productmerchant.com/folder/config.aspx?b=&c=aa
&bb=abcde1&l=en&oc=abc123456
but this resolves to the following url with a 404 not found header
http://myaffiliatemerchant.com/subdomain.productmerchant.com/aa/aa.aspx
P.S Which bb code do i use to stop the links i post here from being clickable?
[edited by: jdMorgan at 10:56 pm (utc) on Sep. 23, 2007]
[edit reason] De-linked [/edit]
In order to pass the query data that you are 'calling' your rule with, you'll need to handle the query data seperately:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.+)$
RewriteRule ^recommend/(.+)$ http://myaffiliatemerchant.com/click?p=123&a=123456&g=123456&url=$1?%1 [R=301,L]
[edited by: jdMorgan at 10:55 pm (utc) on Sep. 23, 2007]