This may be more an apache thing than an ubuntu thing, but I figured this might be a good place to start....
I have an ubuntu 8.04 LTS 64-bit server, running the standard LAMP package, and AllowOverride On so that users can have .htaccess files. I have a user with the following in their .htaccess:
Code:
# Allows .py files to be pulled from Apache without a .py extension
# I.E /about instead of /about.py
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.py [L,QSA]
As stated in the commented lines, this little snippet is intended to python scripts to run without having a .py extension.
I suspect this is causing the Apache server to throw a 500 Internal Server error when a user enters an invalid URL (and thus should be giving a 404 Not Found). The logs, in debug mode, show this whenever an invalid URL is encountered (in this case "http://servername.com/thiswill404_lawlz"):
Code:
$ tail error.log
[Sat Nov 29 22:30:55 2008] [debug] core.c(3052): [client 72.88.145.105] redirected from r->uri = /thiswill404_lawlz.py.py.py.py.py.py.py.py
[Sat Nov 29 22:30:55 2008] [debug] core.c(3052): [client 72.88.145.105] redirected from r->uri = /thiswill404_lawlz.py.py.py.py.py.py.py
[Sat Nov 29 22:30:55 2008] [debug] core.c(3052): [client 72.88.145.105] redirected from r->uri = /thiswill404_lawlz.py.py.py.py.py.py
[Sat Nov 29 22:30:55 2008] [debug] core.c(3052): [client 72.88.145.105] redirected from r->uri = /thiswill404_lawlz.py.py.py.py.py
[Sat Nov 29 22:30:55 2008] [debug] core.c(3052): [client 72.88.145.105] redirected from r->uri = /thiswill404_lawlz.py.py.py.py
[Sat Nov 29 22:30:55 2008] [debug] core.c(3052): [client 72.88.145.105] redirected from r->uri = /thiswill404_lawlz.py.py.py
[Sat Nov 29 22:30:55 2008] [debug] core.c(3052): [client 72.88.145.105] redirected from r->uri = /thiswill404_lawlz.py.py
[Sat Nov 29 22:30:55 2008] [debug] core.c(3052): [client 72.88.145.105] redirected from r->uri = /thiswill404_lawlz.py
[Sat Nov 29 22:30:55 2008] [debug] core.c(3052): [client 72.88.145.105] redirected from r->uri = /thiswill404_lawlz
[Sat Nov 29 22:30:55 2008] [debug] mod_deflate.c(619): [client 72.88.145.105] Zlib: Compressed 711 to 441 : URL /thiswill404_lawlz.py.py.py.py.py.py.py.py.py.py
It looks like Apache is recursively adding .py's to every invalid URL, until it hits the maximum number of internal redirects and gives up, throwing a 500.
Does anyone know of a way to allow us to, uhm, have our cake and eat it, too? In other words, how can we run python scripts lacking a .py extension, without Apache continually adding a another .py to every invalid URL?
thanks for any help!
Bookmarks