Michael S. Fischer
michael at dynamine.net
Mon Dec 22 11:34:16 EST 2003
Daniel J. Popowich wrote: > >>I think the best option for your problem is: >> >>req.headers_out[ "Location" ] = uri >>return apache.HTTP_MOVED_PERMANENTLY #301 >> > > > This won't work for some of what I'm doing, i.e., user goes to a page > that needs authentication so they are redirected to a login page > (without having to save state to a session). There are other similar > situations where, programmatically, you discover that the user should > be somewhere else within your mod_python app and you'd like to > redirect them to other URIs which can check req.prev for existing > state (thus saving network traffic, server hits, etc. Heck, you got > everything you need to know, why tell the client, "go here" when you > can just deliver it in the first place?). > > Also, being the kind of geek that needs to know how and why things > work, I'd like to know why some redirects rewrite my browser url and > some don't; ultimately, I'd like to be able to control the behaviour > with mod_python. I don't know why mod_python is behaving in the manner you describe, but I can tell you that a clear understanding of the HTTP protocol is needed here. Browsers determine what to display in the address bar based on two things only: (1) the URL requested by a user (bookmark, address bar or some other UI mechanism), or (2) an HTTP Redirect: header returned by the server. Without either of those, there is no way for the browser to know that the page requested at /foo/bar can be found in the future at /baz/quux. --Michael
|