CGI question

Ian Bicking ianb at colorstudy.com
Tue Sep 17 15:22:55 EDT 2002


On Tue, 2002-09-17 at 13:04, John D. Boy wrote:
> I am working on a simple CGI script to use as a framework for a website
> of mine. Basically, I want it to work as follows: When somebody accesses
> the site, a CGI (called e.g. index.py) is run. It takes an html-template
> and fills it with content from another file, called e.g. index.dat, and
> returns the completed html-document. When I want to present another
> page, I want the url to look like this: http://my.domain.name/?page. In
> that case, index.py would fill the same template with the content of a
> file called e.g. page.dat. 

BTW, I wouldn't recommend doing it this way.  If you have a cgi script
at, say, /page.py, you can access URLs like /page.py/path/to/something
-- "/path/to/something" will be stored in os.environ['PATH_INFO'].  

Then your URLs will look like real URLs, and not like queries.  And for
mod_rewrite people, if you want to serve the root of your domain off
that script, I believe this will work:

RewriteEngine On
RewriteRule ^/(.*)$ /path/to/page.py/$1

(I don't think you can use Alias in this case, but I might be wrong)

  Ian






More information about the Python-list mailing list