NYCPHP Meetup

NYPHP.org

[nycphp-talk] mod_rewrite -- what's the big deal?

csnyder chsnyder at gmail.com
Tue Oct 3 09:44:04 EDT 2006


On 10/3/06, Cliff Hirsch <cliff at pinestream.com> wrote:

> What difference does it make? To me it mainly looks like a major headache
> making all the queries written in PHP play nicely with mod_rewrite.

This may be going beyond the substance of your question, but
mod_rewrite is arguably the best way to enable a
model-view-controller-ish interface for your web application. A simple
rewrite rule, along with some exceptions for static assets (design
elements, javascript libraries), will funnel everything through your
dispatch script.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/www/.*
RewriteRule ^.* /usr/local/myframework/http-engine.php

Now all requests that don't begin with /www/ get handled by one
script, which can give you big savings in the maintenance and security
departments.

Rewriting doesn't change queries at all, btw. You can pick up the
requested uri from the $_SERVER superglobal, and $_GET vars are set
correctly.

---
Chris Snyder
http://chxo.com/



More information about the talk mailing list