[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apache Redirection/rewriting (fwd)




On Tue, Mar 28, 2000 at 11:57:58AM -0600, Kara Pritchard wrote:

> Ok guys, thought some of you brainiacs could take a look at this. A guy I
> work with at LPI is trying to do some funky stuff with Apache and
> redirection. Instead of simple foo.html redirecting to bar.html, he's
> wanting to redirect it to some cgi script and do some bizarre variable
> substitutions. This isn't my boat, and definitely not my language. I told
> him to email me the stuff, and I'd forward it.
> 
> Below is the examples of what he wants to do. Can he do this? Any
> suggestions?

Sorry for the late reply; I had to think about this one.  WARNING: I'm 
so not an Apache expert.

> Here's what I want to do:
> 
> http://www.somewhere.tld/$2.p[?$3]
>               to
> http://www.somewhere.tld/cgi-bin/p.py?s=$2[&$3]

You want mod_rewrite.

Example: You can hook Zope into Apache, and serve both Zope content
and static/CGI/mod_whatever content.  To do this, you make sure you
load mod_rewrite and do this:

  RewriteEngine on
  RewriteCond %{HTTP:Authorization}  ^(.*)
  RewriteRule ^/Zope/(.*) /usr/local/apache/cgi-bin/Zope.cgi/$1 [e=HTTP_CGI_AUTHORIZATION:%1,t=application/x-httpd-cgi,l]

This sends http://www.example.com/Zope/* to Zope.cgi/*.  The stuff
about authorization has to do with telling Apache to pass auth info on 
directly to Zope, which has its own user management system.

So, something like what you want should be something like:

  RewriteRule ^(.*)/(.*)\.p(.*) /cgi/path/p.py?s=$1/$2&$3

(omitting the weird mod_rewrite options)

Incidentally, if you're doing Python Web programming, you should
really look into Zope.  It's a killer app server written entirely in
Python that has some really wild features.  Check www.zope.org for
details.

--
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.