NYCPHP Meetup

NYPHP.org

[nycphp-talk] Howto create custom URLs

Rob Marscher rmarscher at beaffinitive.com
Mon Mar 19 11:06:36 EDT 2007


On Mar 19, 2007, at 10:46 AM, Donald J Organ IV wrote:

> P.S.   mod_rewrite is usually enabled or can be enabled on any  
> simple hosting plan that is using apache, if you encounter a host  
> that uses apache and wont turn it on, i would suggest finding  
> another host.

Also, you can usually put mod_rewrite rules in a .htaccess file -- so  
it doesn't require httpd.conf access.

Even without mod_rewrite, you could still do myhost.com/index.php/ 
MayEvent07 -- you then look at $_SERVER['REQUEST_URI'], remove  
index.php/ from it, and then explode on / to get your args.

Even if you are able to use mod_rewrite, you probably need to do a  
database lookup to find MayEvent07 so your mod_rewrite rule would be  
something like this:

RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css|html|htm|xml|php)$ index.php

Then you still process it by exploding $_SERVER['REQUEST_URI'] but  
you won't have index.php in that string.  The rewrite rule forwards  
everything to index.php except for files with the extensions listed.



More information about the talk mailing list