On 8 Mrz., 12:18, [EMAIL PROTECTED] wrote:
> On Mar 8, 9:50 pm, "Danilo" <[EMAIL PROTECTED]> wrote:
>
> > Hi there,
>
> > is it possible to create a rewrite rule to send every server-request
> > to the directory /py? But only if the file does not exists on the
> > server.
>
> > This is my mod_python section of the apache config-file.
>
> > <Location "/py">
> >         SetHandler python-program
> >         PythonHandler django.core.handlers.modpython
> >         PythonPath "['/var/www/mydomain.com/htdocs/py'] + sys.path"
> >         SetEnv DJANGO_SETTINGS_MODULE myapp.settings
> >         PythonDebug Off
> > </Location>
>
> For the more general case of where a HTTP 404 error would otherwise be
> returned, indicating that a resource could not be found, as opposed to
> an actual physical file, you can just use:
>
>   ErrorDocument 404 /py
>
> This would be simpler than using mod_rewrite. I can't remember though
> whether the handler when triggered in this case can change the
> response status to something other than 404.
>
> You could use mod_rewrite if you really must, but not sure how it
> would interact with virtual resources managed by some handler where no
> actual file exists. To be practical you would probably want to
> restrict the scope of mod_rewrite to specific contexts.
>
> Quoting an example from very good book "The Definitive Guide to Apache
> mod_rewrite", you can do something similar to:
>
>   RewriteEngine On
>   # If its not here ...
>   RewriteCond %{REQUEST_FILENAME} !-f
>   RewriteCond %{REQUEST_FILENAME} !-d
>   # Look here instead ...
>   RewriteRule ^/images/(.*) /pics/$1 [PT]
>
> In this case it is causing lookups for images to be made in two
> places, but your case wouldn't be much different.
>
> Graham

The rewrite rule works, but now every request ist send to /py.
This is my .conf:

<VirtualHost *>
        DocumentRoot /var/www/mydomain.com/htdocs
        ServerName mydomain.com
        ServerAlias www.mydomain.com

        <Location "/py">
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                PythonPath "['/var/www/mydomain.com/htdocs/py'] + sys.path"
                SetEnv DJANGO_SETTINGS_MODULE myapp.settings
                PythonDebug Off
        </Location>

        RewriteEngine On
        # If its not here...
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Look here instead...
        RewriteRule (.*) /py$1 [PT]

        ErrorLog /var/www/mydomain.com/logs/error.log
        CustomLog /var/www/mydomain.com/logs/access.log common
</VirtualHost>

Any ideas what is wrong?

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to