Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] [OT] Creating user-friendly URLS with mod_rewrite/Apache



On Date: Fri, 18 Aug 2006 13:18:18 +0900, Dave M G <martin@example.com> wrote:
> So what I really want is for Apache and PHP to play nice together so 
> that it will take pretty much anything after the ".com", in the above 
> example where it says "kevin_cooney", and pass that to index.php to be 
> used for looking up data in the database and passing the right information.
> 
> But wait, there's another issue here. On my "tokyocomedy.com" web site, 
> there is an actual subdirectory called "japanese", which is all about 
> the Japanese side of the comedy group, and all the HTML in there is 
> maintained by a different dude than me. So I'd want to make sure that 
> certain exceptions will go to the right directory.
> The tricky part seems to be getting Apache to work without at least some 
> kind of "category" directory. After all, without that, what would I 
> specify in ".htaccess" in order to tell Apache where to take the link?

Most of the popular CMSs use something like the following snippet in an
.htaccess file (or right in the apache config). What it does is essentially say,

If the requested URI matches a real file or directory, proceed as normal.  If
not, call index.php (or whatever you set it to) which then needs to take care of
the request one way or the other (for example send 404 if it's a missing image
file)


RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php


HTH,
Dave


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links