Forum Moderators: phranque

Message Too Old, No Replies

redirect with url as parameter not working

         

bpdp

2:57 pm on May 18, 2011 (gmt 0)

10+ Year Member



My company is tracking pdf downloads with a third party. We're in the process of changing companies so natutally I don't want to search thru the source to find every pdf link. I thought it would be an easy htaccess solution but I'm having problems:


# this does not work
Redirect 301 /wp-content/themes/THEME_NAME/js/elq_now/elqRedir.htm?ref=http://SITE.com/pdf/datasheets/X0202.01_PDF_NAME.pdf http://go.pardot.com/l/7112/2011-05-16/XOXO



# removing the parameter works but then all pdf links will lead to the same destination.
Redirect 301 /wp-content/themes/THEME_NAME/js/elq_now/elqRedir.htm http://go.pardot.com/l/7112/2011-05-16/XOXO


I'll take any help anyone could give. Apache is a mysterious black art to me. Thanks.

g1smd

3:07 pm on May 18, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Redirect pattern matching cannot "see" query strings.

You will need RewriteRule to test the path and filename, and a preceding RewriteCond to test the QUERY_STRING data. The redirect target will contain the domain name and use the [R=301,L] flags.

bpdp

5:25 pm on May 18, 2011 (gmt 0)

10+ Year Member



Thanks for the reply g1smd. I've been trying to get this to work for a few hours and I can't see what I'm doing wrong. I would think this would be easy as I don't really need any regex's. I've tried a lot of different combinations of below but this is the most basic version that I would think should work.


Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} http://SITE.com/pdf/datasheets/X0202\.01_PDF_NAME\.pdf
RewriteRule ^wp-content/themes/THEME_NAME/js/elq_now/elqRedir\.htm http://go.pardot.com/l/7112/2011-05-16/XOXO [R=301,L]


I'm not really seeing a difference between my code and the example I was working from:


RewriteCond %{QUERY_STRING} val
RewriteRule ^/page1 /page2

g1smd

6:07 pm on May 18, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Your query string pattern has slashes in it, which are invalid. Slashes are not allowed in a query string. They will need to be ASCII encoded when in a query string.

bpdp

8:15 pm on May 18, 2011 (gmt 0)

10+ Year Member



thanks g1smd, guess I'll have to just edit the source then. oh well.

Thanks again for your help.