in reply to Minimizing paths?
You can easily utilize ScriptAlias directives in Apache for this, which allows you to tell the webserver that URLs like /serve.pl/arguments/go/here should be executed by the CGI script, and that serve.pl is not to be interpreted as a directory name. The stuff in the URI after serve.pl will be placed in $ENV{PATH_INFO}, so modifying your code is easy. You should be able to just change your code from using param('page') to the PATH_INFO environment variable instead, and everything should still work.
Here's how you can get ScriptAliases to work:
If you have access to the httpd.conf file, you can add a ScriptAlias for the individual script in question. It can be anywhere in the httpd.conf file and will look something like this:
Alternatively, if you don't have access to the httpd.conf file, many ISPs configure your /cgi-bin directory to automatically use ScriptAliases, so anything in that directory will be configured properly for this.ScriptAlias /serve.pl "/usr/local/apache/htdocs/serve.pl"
So now, all you have to do is rewrite your HTML parser to use the URI format instead of the query-string argument format. Now when you have a page /serve.pl/foo/bar.html, which has a link to ../perl.html in its HTML, the browser will do all the work on its own and come up with a URL that your script can accept as-is.
The only work that really needs to be done is with absolute links. But that's trivial! Just prepend the location of your script to the beginning of all HREFs starting with a slash. /index.html becomes simply /serve.pl/index.html.
Best of luck,
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Minimizing paths?
by Joost (Canon) on Sep 17, 2002 at 10:41 UTC |