128 Chapter 4 Web Application Concepts Figure 4.1 Amazon.com hides the session ID in the URL. Dynamic Paths with mod_rewrite You can avoid at least the hassle of manually encoding the session ID with a clever trick.What if the URL looked like this? http://server.com//page.php3 The browser would automatically send the session ID on every request, treating it as part of the directory. Of course, if you try to use this format as is, you ll only get a File Not Found error,because there s no directory that looks like the session ID.We need a way to remove the session ID from the path before the Web server actually sees the URL. This is where mod_rewrite comes into play.This is an Apache module that applies complex regular-expression transformations to a URL before passing it to the Apache server. Using mod_rewrite, we can simply strip out the session ID from the URL; this is an internal change to the URL, and only Apache will see it the client won t. Apache will see a normal request without session ID, while it s still available in the usual variables for PHP. Getting mod_rewrite The mod_rewrite module is not compiled into Apache by default. Please see Apache s INSTALL file for instructions on how to compile Apache with this module.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services
No comments yet.
Sorry, the comment form is closed at this time.