Keith Devens .com |
Friday, March 19, 2010 | ![]() |
| Linux is only free if your time has no value – Jamie Zawinski | ||
mod_rewriteThis is the only set of mod_rewrite rules I ever use: RewriteEngine OnThat makes any .php file automatically extensionless (without having to do any multiviews or content negotiation or whatever), and dispatches all requests that don't result in an actual file to a "front controller" named dispatcher.php. In conjunction, I often use: DirectoryIndex dispatcher.php In order to make dispatcher.php work automatically at the root. Lastly, in Apache 2, you can turn off mod_dir's "slashification" so that if you have public_html/foo.php and public_html/foo/bar.php, it won't think when you type in /foo as a URI that you want the directory public_html/foo/, but rather public_html/foo.php: DirectorySlash OffI personally don't like having slashes at the end of any url (besides the root), so I have code in my dispatcher that redirects you to the unslashified URL if a URL with a trailing slash is visited (try it). I also make sure Multiviews and directory indexes are off with: Options -MultiViews -IndexesPage last edited: December 13, 2005 (utc) |
IndexA B C D E F G H I J L M N O P R S T U V W X All pagesABC
DEFGHIJLMNOP
RS
T
UVWXGenerated in about 0.036s. (Used 4 db queries) |