[mydomain.com...] the script [mydomain.com...] is run and the output displayed, invisible to the user.
Similarly if they go to [mydomain.com...] the script [mydomain.com...] is run.
This should work for whatever html page they go to(i.e not pre determined).
Can this be done by changing the .htaccess file?
Rewrite URL [httpd.apache.org]
I think what you are looking for is at or near the bottom?
I assume you are talking about the sections entitled:
* From Static to Dynamic
* On-the-fly Content-Regeneration
However, would someone mind explaining this to me in simpler terms(I am all but a beginner at this:-) How does this relate to what I want to do, as in translating script.cgi?keyword=apples into apples.html. Also how does this relate to the .htaccess file?
Any help, much appreciated.
Every time a page or object (a file) is requested from your server, the .htaccess files in the path along the way to that file are examined by the server. mod_rewrite directives can be included in any or all of those .htaccess files. mod_rewrite is used to rewrite URLs or pathnames - to modifiy them.
Therefore, you can write a set of directives for mod_rewrite to use to translate a request for
/<anyfruit>.html into a request for /script.cgi?keyword=<anyfruit>.
This can be used to translate "friendly" URLs requested by visitors and search engine robots into the script path and parameters you need. The flip side is that you need your script to output friendly URLs as well so that these URLs will be used for bookmarks and search engine listings. It is up to the script to do, since .htaccess is processed only before a request is served.
HTH,
Jim
The current file has only one line
--------------------
ErrorDocument 404 /404.html
--------------------
What exactly do I need to add to this to tanslate to translate a request for /<anyfruit>.html into a request for /script.cgi?keyword=<anyfruit>?
If yes, have it read the PATH_INFO data instead of the cgi-input variables. Just strip off the .html extension and any leading /, and use the rest as your keyword.
Then have you script run for all files in the folder. With apache this would be
ScriptAlias / <server-dir>/cgi-bin/script.cgi
This means that /apples.html will be changed into
/cgi-bin/script.cgi/apples.html
The superflous part of the path is the PATH_INFO, in this case /apples.html
This might be easier to handle than mod_rewrite, which can be rather daunting.
René.
Here is a good thread:
[webmasterworld.com...]
I'm still looking for a good beginners tutorial.
From post #8 of the above link:
The tricks of the trade involve using mod_rewrite to serve requests for /news/12.html from news.php?id=12Assuming you have apache with mod_rewrite enabled then that example could be accomplished with:
RewriteEngine on
RewriteRule ^/news/(.*)\.html$ /news.php?id=$1
I would sure like the 'rule' portion explained, step by step.
I realize it's not cgi, but I imagine the rule is similar.
What exactly do I need to add to this to tanslate to translate a request for /<anyfruit>.html into a request for /script.cgi?keyword=<anyfruit>?
ErrorDocument 404 /404.html
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ /script.cgi?keyword=$1 [L]
Basically, the "$1" back-references the contents of the parentheses, which are specified here as "anything preceding '.html'."
Mod_rewrite is very powerful. It is also complex in and of itself, and complex because it uses regular expressions pattern-matching. For more info, see the Apache mod_rewrite documentation [httpd.apache.org], and this short regex primer [etext.lib.virginia.edu].
HTH,
Jim
At the momemnt, the script is:
use CGI qw/:standard/;
use HTTP::Request;
use LWP::UserAgent;
$query = new CGI;
$ua = LWP::UserAgent->new;
$st = $query->param('keyword');
so for script.cgi?keyword=apples, in this script $st takes the value of apples. So, instead how can I get $st to take
apples from /apples.html(-->/cgi-bin/script.cgi/apples.html )