URL Rewriting for Beginners
addedbytes.com
URL Rewriting for Beginners
1–10 of 16 posts
Re: URL Rewriting for Beginners
#2Re: URL Rewriting for Beginners
#3I'm part of the "I don't do this myself, but I manage people who do" crowd. It's always good to see these types of articles on here. They keep us from being totally ignorant about the mechanics of our own projects. Thanks!
Re: URL Rewriting for Beginners
#4It's almost always a better idea to do this another way. Note that the distinction between the "handler" part of the URL, the remaining "path-like" part and the query string is already exposed in the CGI variables (SCRIPT_NAME, PATH_INFO, and QUERY_STRING). The handlers can do this magic on their own. Doing it by placing important application code into the apache configuration for the site strikes me as very confusing.
Re: URL Rewriting for Beginners
#5
SetHandler mod_python
PythonHandler DoStuff
Any request starting with /dostuff gets passed to DoStuff handler and you can parse the url pieces in the handler itself: from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
print >> req, 'uri = %s' % req.uri
print >> req, 'filename = %s' % req.filename
print >> req, 'path_info = %s' % req.path_info
return apache.OKRe: URL Rewriting for Beginners
#6It needs to be pointed out that this kind of trick is essentially a workaround for the awful URLs caused by the "the URL is the path of the handler" scheme that Apache and PHP like to encourage. It's almost always a better idea to do this another way. Note that the distinction between the "handler" part of the URL, the remaining "path-like" part and the query string is already exposed in the CGI variables (SCRIPT_NAM…
Re: URL Rewriting for Beginners
#7Re: URL Rewriting for Beginners
#8Bah, mod_rewrite is for sissies! Parse the url in your handler code! SetHandler mod_python PythonHandler DoStuff Any request starting with /dostuff gets passed to DoStuff handler and you can parse the url pieces in the handler itself: from mod_python import apache def handler(req): req.content_type = 'text/plain' print >> req, 'uri = %s' % req.uri print >> req, 'filename = %s' % req.filename print >> req, 'path_info…
Re: URL Rewriting for Beginners
#9Kohana (PHP Framework) has pretty good URL rewriting resembling RoR's. /controller/method/variable. (/user/edit/1005 would reference application/controllers/user.php, class User_Controller, function user(1005).) POST/GET/PUT/etc are retained.
Re: URL Rewriting for Beginners
#10Bah, mod_rewrite is for sissies! Parse the url in your handler code! SetHandler mod_python PythonHandler DoStuff Any request starting with /dostuff gets passed to DoStuff handler and you can parse the url pieces in the handler itself: from mod_python import apache def handler(req): req.content_type = 'text/plain' print >> req, 'uri = %s' % req.uri print >> req, 'filename = %s' % req.filename print >> req, 'path_info…