Keith Devens .com |
Monday, December 1, 2008 | ![]() |
| If you rely on scale up, you’ll probably get killed. You should always be relying on scale out. – Phil Smoot | ||
|
| ← What Darwin had to say about Evolution | PHP-Nuke forks → |

Reverend Jim (http://revjim.net/) wrote:
Keith (http://www.keithdevens.com/) wrote:
Wow! I never knew that existed before. So you can really get a lot of the benefit of mod_rewrite by using that. This tip goes in my pocket for later 
Alister (http://abulman.co.uk) wrote:
I use PATH_INFO a lot - like this book review site.
http://www.newbookreviews.co.uk/books/export/javascript/usercat/10/1
Here, export is the program, and the rest are parameters - for example, I can change the javascript for 'xml', or php, for PHP serialised data.
Keith (http://www.keithdevens.com/) wrote:
Hey Alister, what do you use to get rid of the extension for 'export'? Do you use ForceType? I just noticed there's a DefaultType directive which can be used to do a similar thing, so I'm wondering what other ways there are to accomplish this.
Reverend Jim (http://revjim.net/) wrote:
Since it doesn't look like Alister is going to answer you, I will tell you one easy way.
It requires apache, but you do this (replacing [ and ] with < and > respectively):
[Files export]
ForceType application/x-httpd-php
[/Files]
Another way, which I think is REALLY slick, works only if you have ONE script that you wish to use as your "controller" to launch everything else. Let's assume that your controller is called controller.php and it resides in your document root. This example also requires Apache and additionally, mod_rewrite.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ controller.php/$1
Both of the above examples are untested, but you get the idea, I think.
Keith (http://www.keithdevens.com/) wrote:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\. dispatcher.php
Hey Jim, that's the text above is exactly what I use in my public_html .htaccess file (with some comments removed). A few notes: Right now I only check if the directory exists. If the directory exists I leave it alone. Also, if the file has a period in it, I leave it alone so "normal" files, either .gif's etc. or .php's will be unaffected by the content management system. Finally, instead of capturing the URL and passing it to the controller with $1, I just get the URL info from the environment in my "dispatcher.php" (which you named controller.php) 
Thanks for the explanation of ForceType.
Reverend Jim (http://revjim.net/) wrote:
Wow.
I think you and I are writing (or you're writing, and I'm thinking about writing) the same things.
Although, at this time, I have no code to offer, would you be interested in pooling our resources?
Keith (http://www.keithdevens.com/) wrote:
I would love to pool our resources 
We seem to have pretty much the same goals... I just keep going back and forth with conceptual problems. When I get home later I'll send you an e-mail with a summary of what I have and some sample code.
Keith (http://www.keithdevens.com/) wrote:
Yeah, I stayed over my friend's house. I'll hit you up later 
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):
Generated in about 0.219s.
(Used 8 db queries)

It doesn't show up in your phpinfo() unless you actually USE it. For instance, if you visit http://test.revjim.net/php.php you see no mention of PATH_INFO. However, if you visit http://test.revjim.net/php.php/some/path/info/here, you'll see it.