heyman has asked for the wisdom of the Perl Monks concerning the following question:

I don't mean to ask such a dumb question but I'm going to anyway.

How do you load a script at one location:
EX. http://www.mysite.com/cgi/myscript.cgi

but actually tell the browser that the location you are at
EX. in javascript  document.location is http://www.myothersite.com/helloworld.html?

ADAM

  • Comment on load a script at one location BUT the browser thinks im somewhere else.
  • Download Code

Replies are listed 'Best First'.
Re: load a script at one location BUT the browser thinks im somewhere else.
by mr.nick (Chaplain) on Mar 28, 2001 at 19:23 UTC
    This is a truly cheesy solution, but one that I've applied a few times to (partly) hide URLs. Use Frames:
    <frameset rows="*"> <frame src="http://www.mysite.com/cgi/myscript.cgi"> </frameset>
    The browser will only display the URL that is hosting this page, not the source of the frame.
Re: load a script at one location BUT the browser thinks im somewhere else.
by physi (Friar) on Mar 28, 2001 at 19:11 UTC
    I think your trying to access a page (i.e. http://www.mysite.com/cgi/myscript.cgi )
    by a URL like www.whereever.com/helloworld. Assuming your script is a perly-one,
    you can use mod_perl (assuming again that u use apache) for doing this.

    httpd.conf:
    <Location /HelloWorld> SetHandler perl-script PerlHandler YourScript::asAmodul </Location>
    see more about this at: http://perl.apache.org/guide/porting.html#Converting_to_use_Apache_Perl_Mo

    If you're not using apache, ignore this message :-)
    --physi--
Re: load a script at one location BUT the browser thinks im somewhere else.
by Masem (Monsignor) on Mar 28, 2001 at 17:50 UTC
    I do believe that you can set something up like that in Apache's (or whatever web server you are running) conf, as to make the server at www.mysite.com as a different name (See the ServerName var), but this is beyond the scope of perl. However, if you don't own www.myothersite.com, this is going to be both ethically rude and a potental legal problem if you don't have permission from www.myothersite.com to do this.
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
Re: load a script at one location BUT the browser thinks im somewhere else.
by sutch (Curate) on Mar 28, 2001 at 19:16 UTC
    I don't believe that you can tell the browser that it is at a different location than the location that it requested. For example, if the user requests www.mysite.com, (I believe) there is no way to tell the browser that content is being returned from a different address.

    mod_proxy may be what you are looking for, but that may be overkill.

    If I correctly understand what you want to do, you could have users request documents from http://www.myothersite.com/helloworld.html? and use Apache's ScriptAlias directive to execute /cgi/myscript.cgi. This has worked for me in the past, allowing two host names to map to one script. It also allows for testing of the host name (using CGI.pm's url() method) to provide slightly different/tailored output depending on the host requested.

Re: load a script at one location BUT the browser thinks im somewhere else.
by heyman (Novice) on Mar 28, 2001 at 18:41 UTC
    no i do have ownership of both sites but i am on a virtual host rather then a dedicated one, is this a problem?