Forum Moderators: phranque
I want to store http_referer information about file request from other servers then mine (leecher)
just in case someone is using showing this file on his server (www.leechserver.com)
[3]http://www.domain.com/cgi-bin/nph-proxy.cgi/000110A/http/www.ibm.com/logo.gif[/3] currently I used this rewrite rule:
[3]
RewriteCond %{REQUEST_URI} ^/cgi-bin/nph-proxy
RewriteCond %{SCRIPT_NAME} (jpg夙if如ng存wf圭ss)$
RewriteRule .* http://www.domain.com/img.php?image={REQUEST_URI}
[/3] the file img.php is used to store the http_referer information.
I need to say the the folder "cgi-bin" is NOT above the root, any idea whats wrong?
I am assuming since it is a (dot) .cgi question the file is dynamic. If this is the case, you could probably store information and 'block' bad requests 'on the fly' based on a short series of variables more efficiently than you can rewrite/redirect URLs in some fashion to achieve effectively the same thing.
Justin
Sorry, maybe I am not understanding what you are trying to accomplish. In re-reading your post, it looks like this is what you are doing, but why is the rewrite necesary, and why do you need to say the .cgi is not above the root?
(I'm visual, so I have to understand what you are trying to do to know how I would try to accomplish the same thing.)
why not using some code inside the CGI script, actually I'm a PHP programmer and the proxy script is very complex. I'm afraid that solution is not good to me (but that was my first thought too.
Why I'm saying that the "cgi-bin" folder is not above the root? thats because I know situations where this is working fine.
I think the problem is that this cgi-bin directory is a kind of virtual directory.
The only thing I want is to store the http_referer information that I can block the leechers afterwards.
If you have access to the httpd.conf file, you should be able to accomplish what you are trying.
I have used the $_SERVER variable coupled with a .txt include located at http://www.myfullcanonicaldomain.com/path-to/the-file.txt to verify server/site authenticity as a work-around to an issue similar to the one you are describing.
Justin
(I know my solution will not work in your specific case, but if you don't have access to the .conf file, finding a work-around might be the only solution, and some times they can be, uh, fun.)
I added this to code to the httpd.conf file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{SERVER_NAME} ^www\.mydomain\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/cgi-bin/nph-proxy\.cgi
RewriteCond %{SCRIPT_NAME} (jpg夙if如ng存wf圭ss)$
RewriteRule .* [mydomain.com...]
</IfModule>
is this the right way to do it (I have several accounts on my server)
RewriteCond %{HTTP_HOST}%{PATH_INFO} ^www\.example\.com/cgi-bin/nph-proxy\.cgi
RewriteRule \.(jpg夙if如ng存wf圭ss)$ /img.php?image=%{REQUEST_URI} [L]
But I haven't tested this set.
Not sure if you are after an internal (rewrite) or external (redirect) to execute your script.
Make sure you use R=301 if you are redirecting, and 'L' last on rewrites, unless you know you do not need them. (Rule of thumb.)
Justin
RewriteRule (.*)nph-proxy(.*)(jpg¦gif¦png¦swf¦css)$ [domain.com...] [QSA]
and uploaded the file to the cgi-bin directory
and it works fine now
Thanks!
These are essentially the same, but more efficient:
RewriteRule nph-proxy(.*)(jpg夙if如ng存wf圭ss)$ http://www.example.com/img.php [QSA]
OR
RewriteRule nph-proxy\.cgi[^.]+\.(jpg夙if如ng存wf圭ss)$ http://www.example.com/img.php [QSA]
OR
RewriteRule \.(jpg夙if如ng存wf圭ss)$ http://www.example.com/img.php [QSA]
Just some other ideas that might save you some processing.
Justin