NYCPHP Meetup

NYPHP.org

[nycphp-talk] One more question about Friendly URLS

Tom Melendez tom at supertom.com
Thu Mar 8 15:04:00 EST 2007


> Using an absolute path gets you none of the troubles you mentioned with
> relative path, and none of the caching problems you'd get with an
> absolute URL.

The only trouble I have found with absolute paths is that it makes the
assumption of DocumentRoot and where your files are to it.  If all of
your environments (dev, staging, qa, production, running off media,
whatever) are set up the same way, no problems.

But, using absolute paths removes the ability to just copy a bunch of
files in a directory and run them.  Now, in today's day, our sites are
now "applications" and you probably couldn't do that anyway.  Still,
if you did, I found the following to work in the past:

Simply make the call to the css file a PHP script, which has the
'smarts' to figure out where the CSS file is based on the URL
provided.  The PHP script still has to live absolute to the Document
Root, but it can act as a "traffic cop" to determine which CSS file
should be loaded.  So, something like:

<link rel="stylesheet" type="text/css" href="csshandler.php?p=foo.php">

FWIW, I really don't do this anymore, and even when I did, it was only
in development (because you'd want to be sure that files weren't
getting served up that shouldn't be) on my laptop.  But it gets around
the problem.


Tom
http://www.liphp.org



More information about the talk mailing list