Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

OT: Apache/perl question

by Cody Pendant (Prior)
on Dec 19, 2007 at 01:15 UTC ( #657771=perlquestion: print w/ replies, xml ) Need Help??
Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone give me advice on how to set up the following thing?

Say I want to serve HTML from this URL:

http://myserver.com/directory/anotherdirectory/

But what's really going on is that directory is a perl CGI script which gets /anotherdirectory/ as its $ENV{QUERY_STRING}.

I know I can do that using Apache rewrite rules for "if directory doesn't exist", but I could swear I've seen it done a different, simpler way, where the filename "directory" is identified as an executable perl script and there's some kind of 'accept from all' magic and somehow it Just Works.

Am I crazy?



Nobody says perl looks like line-noise any more
kids today don't know what line-noise IS ...

Comment on OT: Apache/perl question
Select or Download Code
Re: OT: Apache/perl question
by aquarium (Curate) on Dec 19, 2007 at 01:54 UTC
    using slashes is an old way of separating parameters in urls. it should still work as long as apache can quickly grasp that "directory" is a cgi. so if "directory" is a scriptalias in apache config, and exists as an executable script, then it will work
    btw this question has nothing to do with perl per se. check doc/faq/forum at apache.org
    the hardest line to type correctly is: stty erase ^H
      btw this question has nothing to do with perl per se
      I did put "OT" in the title, for that reason.


      Nobody says perl looks like line-noise any more
      kids today don't know what line-noise IS ...
        That doesn't play
Re: OT: Apache/perl question
by NetWallah (Abbot) on Dec 19, 2007 at 01:55 UTC
    Perhaps you can rephrase your question to make more sense.

    For what you appear to want,

    • "directory" would be a directory with a default script (CGI).
    • "anotherdirectory" can be passed as a querystring if the URL is something like
      http://myserver.com/directory?anotherdirectory
      Note the change from SLASH to QuestionMark.
    • I believe leading and/or trailing "/" marks would work fine around the querystring, if necessary

         "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom

      Thanks for rephrasing, but I do want exactly what I said I want -- "directory" would be a perl script, and there would be no question marks in the URL. I already know how to do it your way.


      Nobody says perl looks like line-noise any more
      kids today don't know what line-noise IS ...
Re: OT: Apache/perl question
by pfaut (Priest) on Dec 19, 2007 at 02:12 UTC

    Any directories past the script name will be available in $ENV{PATH_INFO} or $query->path_info if using CGI. That's where you'll find your /anotherdirectory.

    90% of every Perl application is already written.
    dragonchild
      Thanks dragonchild.

      I've got it working, thanks to that. If the directory it's in is identified to Apache with the ScriptAlias directive, any file no matter what the extension can run.

      So if you have a script called 'directory' in a ScriptAlias folder foo and you go to the URL http://server.com/foo/directory/bar/baz the script will run and you get /bar/baz in $ENV{PATH_INFO}



      Nobody says perl looks like line-noise any more
      kids today don't know what line-noise IS ...
Re: OT: Apache/perl question
by maverick (Curate) on Dec 19, 2007 at 17:03 UTC
    Hmmmm....I have the sneaking feeling that this might lead to caching issues. Squid for example looks for a ? in the URL as a hint to know if something can be cached or not.

    /\/\averick

      If it does, then its broken. The presence of a query string shouldn't have any influence on caching, it means nothing other than "This URI could have been generated with a form and user provided data".

      http://search.yahoo.com/search?p=perl has a query string, but the significant content of that page is likely to change less frequently then that of http://perlmonks.com/ (which doesn't).

      If a tool wants to do sane caching, then it should pay attention to HTTP's collection of cache control headers.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://657771]
Approved by NetWallah
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-08-21 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (144 votes), past polls