Can Wsgi Get The Full Url Rather Than Simply : Environ['server_name'] ?.. If So.. Mod_rewrite Alternative?
Solution 1:
It cannot really replace mod_rewrite if the intent is that the rewritten URL be fed back in as a sub request into Apache as a whole with request content still available. All you can really do is perform URL rewriting for use of the URL and request within a specific Python WSGI application.
The qualification on the first about request content is that when using daemon mode of mod_wsgi, it is possible to return a 200 response with no content and a Location response header, where the value of the Location header is a server relative URL. This will cause a new sub request to be performed at the Apache level, but in doing that it can only issue a GET request with no request content.
The 200/Location response can thus be used as a way for a WSGI application to reroute a request the WSGI application handles back to Apache to serve up a different resource, such as a static file or even a PHP application. This is by no means though a general mechanism that could be used to replace mod_rewrite and would only be suitable in certain use cases.
And on the specific point of access to other parts of the original request information, you have:
- SERVER_NAME
- SCRIPT_NAME
- PATH_INFO
See for example URL reconstruction in the WSGI specification at:
Under Apache/mod_wsgi you also have REQUEST_URI, but that can be complicated to deal with as is not decoded nor normalised and can be a server relative URL or technically a URI format including scheme and host/port information.
Post a Comment for "Can Wsgi Get The Full Url Rather Than Simply : Environ['server_name'] ?.. If So.. Mod_rewrite Alternative?"