I'm using Apache, Python (fastcgi), mod_rewrite.
I want
http://foo/bar
to redirect internally to
http://main.py?q=foo/bar
Now my .htacess file contains
Options +ExecCGI
AddHandler cgi-script .py
DirectoryIndex main.py
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) main.py?q=$1
Normally works fine. Redirects to main.py with the query-string q=foo/bar But if I have a script named foo.py it instead directs to foo.py instead of main.py.
I tried removing the RewriteConds and have the RewriteRule alone as a catch-all.
Then it always redirects to main.py ok, but the query-string passed to my script is q=main.py where it should be q=foo/bar
Now there's various kludges I could try involving restructuring my code, file layout etc, but I'd like figure out what's going on before it causes more problems down the track.
So I want to either a) stop it thinking that foo means foo.py or b) make it skip the existing file checks completely and pass on the correct query-string.