View Single Post

  #1 (permalink)  
Old 04-22-2008
Bruno Rafael Moreira de Barros
 
Posts: n/a
Default Problem with my Search Engine Friendly URLs in PHP.

I have this framework I'm building in PHP, and it has Search Engine
Friendly URLs, with site.com/controller/page/args... And on my View
files, I have <?=$this->baseURL;?> to print the base URL on the links
(eg. <a href='<?=$this->baseURL;?>/controller/page/args'>Go somewhere</
a>. But on the CSS / JS files, how will I do it? I wonder, because on
the View files, I can do <?=$this->baseURL;?>/css/site.css, and it
will work. But images on the CSS stylesheet don't have the same
possibility, and they can't be static URLs for code portability, nor
they can be relative URLs because they would just get added to the
Search Engine Friendly URL.

I have considered replace some kind of special tag on the files, and
then have PHP get and serve the files, but that would cost too many
resources, and would break your CSS / JS on your editors.

The only solution I see is renaming the CSS and JS files to .php and
making some kind of wrapper in PHP to include them, providing them the
baseURL variable, like:

$baseURL = 'something';
include($requested_css_file);

Besides solving my issue, I would also be able to configure Etags,
Expire headers, gzip the files, and all the things YSlow recommends
for website performance improvement.

By the way, Zend Framework doesn't require me to rename .css or .js
files (and then again, I don't really know how they make it work).

But I was wondering...Do you know of any better solution?


Thanks in advance.
Reply With Quote