Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

•Re: cgi redirect

by merlyn (Sage)
on Nov 26, 2002 at 19:24 UTC ( [id://215908]=note: print w/replies, xml ) Need Help??


in reply to cgi redirect

If it's on a different server, you'll need to fetch the data yourself and proxy it by rewriting all the URLs. I have a column on that, of course.

If it's on the same server, you can do an "internal" redirect rather than an "external" redirect as you've done. To the browser, nothing has happened. The server is just told via a URL that starts with / instead of http: that it should start over again with a different URL on this server. Again, you have to worry about leakage, and relative URLs, but it's a fairly quick solution and may be exactly what you're looking for.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: cgi redirect
by The_Rev (Acolyte) on Nov 26, 2002 at 19:44 UTC
    That does indeed work, but the URL for the specific page is still displayed in the path on the browser...Is it possible to use an internal redirect without the URL changing to the user
      Poor man's solution:
      #!/usr/bin/perl use strict; use warnings; use LWP::Simple my $url = 'http://some.domain/some/path/to/file.htm'; my $content = get $url; $content =~ s|</head>|<base href="$url"></head>|is; print "Content-type: text/html\n\n$content"; exit(0);

      If you want to keep all links internal, it will take a while - especially if you take some time to think about why you want to mis-represent content's origin to users on that large a scale.

      .02

      cLive ;-)

      That does indeed work, but the URL for the specific page is still displayed in the path on the browser
      I'm not sure what you mean. If you put:
      print "Location: /icons/left.gif\n\n";
      at /cgi/leftarrow, it'll run the script and display a left arrow, but the URL will still remain the CGI location. I thought that's what you wanted.

      Actually, you may be running a non-standard web server (something other than Apache). If that's the case, you should disclose that so I stop trying to bring Apache-specific knowledge into the discussion.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Sorry Merlyn, for the long delay in my response. I am using apache, and I do need to hide the url path displayed in the browser from the user.

        I'm a little unclear as to what you mean with :

        at /cgi/leftarrow, it'll run the script and display a left arrow, but +the URL will still remain the CGI location.
        Thanks

      I'm not aware how to do this with a CGI-Script. It might be possible with mod_perl, though.

      Take a look at the Apache module mod_rewrite; that should do what you want.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://215908]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2025-06-18 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.