Moonlit Monks,

My Perl script at www.anotherdomain.com/cgi-bin/bar/myscript.pl needs to redirect to an html page that is at www.mydomain.com/foo/page.htm To ensure that this page can be accessed only by a redirect from my script - I know I'll get heat for this, but bear with me - I propose to put an htaccess file in the foo directory that will accept requests only from one specific, imaginary, referer. Then, have myscript set the referer header that accompanies its redirect.

To do that, I lifted this code from here:

http://www.microsoft.com/mspress/books/sampchap/5612c.aspx

use HTTP::Request::Common qw(POST GET); use LWP::UserAgent; $ua = LWP::UserAgent->new(); $req = POST 'http://www.northwindtraders.com/dologin.asp', [ Username => 'mike', Password => 'mypa$w0rd', ]; $req->header(Referer => 'http://www.northwindtraders.com/login.html'); $res = $ua->request($req);
changing northwindtraders.com to mydomain.com

But it doesn't work for me. I get the dreaded Server Error.

Any advice on either how to make this code work, or other ways to do the same thing, would be greatly appreciated.

Thanks.




Time flies like an arrow. Fruit flies like a banana.

In reply to Setting referer with HTTP::Request and LWP::UserAgent by punch_card_don

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.