Hi there,

got it figured out. Here's my .htaccess:

RewriteEngine On
RewriteBase /
# break after this rule to avoid firing the second rule for static files
RewriteRule ^([^/]+)/static/(.*)$  /applications/$1/static/$2 [L]
RewriteCond %{REQUEST_URI} !^/cgihandler\.py/
RewriteCond %{REQUEST_URI}  !^/applications/([^/]+)/static/
RewriteRule ^(.*)$ /cgihandler.py/$1

ScriptAlias and AliasMatch only work in httpd.conf, so putting these in 
.htaccess would not work. The real magic - i.e. the difference from my 
earlier attempts - probably is "RewriteBase /" and not starting the 
RewriteRule patterns with /.
The first rewrite rule has the benefit of not routing static file requests 
through cgihandler.py. Instead, these requests are served by Apache which 
makes a huge difference in load times for me. It's also easier to add 
far-future expires headers this way, as web2py only does that for files 
with version strings in their name (?).

Hope that helps someone.

Kind regards,

Michael

Am Samstag, 16. Februar 2013 23:22:48 UTC+1 schrieb Michael Haas:
>
> Hello all,
>
> my webhost only offers Python in CGI mode, so I'm currently using 
> cgihandler.py which works reasonably well.
>
> My current URL is http:/host/cgihandler.py/ which shows the main page of 
> my application just fine. However, I'd like the URL to be just 
> http://host/ without the cgihandler.py/ part.
>
> Things I have tried in .htaccess:
>
> * ScriptAlias / /cgihandler.py/ - Just results in HTTP 500
> * RewriteRule ^/(.*) /cgihandler.py/$1 - Just results in HTTP 404 for 
> http://host/ and "invalid function default/cgihandler" for 
> http://host/cgihandler.py/
> * AliasMatch ^/(.*) /cgihandler.py/$1 - HTTP 500 again
>
> So, I have a feeling I'm missing something fundamental here - any clues?
>
> My routes.py:
>
>     routers = dict(
>     # base router
>         BASE = dict(
>             default_application = "Sarge",
>             #path_prefix = "cgihandler.py",
>         ),
>     )
>
> Of course, path_prefix is enabled for regular operation where I use the 
> cgihandler.py suffix in the URL.
>
> Kind regards,
>
> Michael
>    
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to