This is a discussion on Problem with my Search Engine Friendly URLs in PHP. within the PHP Language forums, part of the PHP Programming Forums category; I have this framework I'm building in PHP, and it has Search Engine Friendly URLs, with site.com/controller/...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros
<brunormbarros@gmail.com> wrote: > 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;?> Don't rely on short_tags, and especially not on <?=$var;?> syntax.. > 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. Unless there's an extra path not in your example, if in baseURL there only is a domain name, you can leave it out all together... href="/css/site.css" will just get it relative from the root, which ismy preferred method. -- Rik Wasmus |
|
|||
|
On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros > > <brunormbar...@gmail.com> wrote: > > 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;?> > > Don't rely on short_tags, and especially not on <?=$var;?> syntax.. > > > 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. > > Unless there's an extra path not in your example, if in baseURL there only > is a domain name, you can leave it out all together... > href="/css/site.css" will just get it relative from the root, which is my > preferred method. > -- > Rik Wasmus Yeah but the problem is if my scripts are not deployed on the root... It is really bad. |
|
|||
|
Bruno Rafael Moreira de Barros wrote:
> On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote: >> On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros >> >> <brunormbar...@gmail.com> wrote: >>> 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;?> >> Don't rely on short_tags, and especially not on <?=$var;?> syntax.. >> >>> 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. >> Unless there's an extra path not in your example, if in baseURL there only >> is a domain name, you can leave it out all together... >> href="/css/site.css" will just get it relative from the root, which is my >> preferred method. >> -- >> Rik Wasmus > > Yeah but the problem is if my scripts are not deployed on the root... > It is really bad. > Why? It works fine. If you're talking about using include(), require_once(), etc., that's a different story. But the client doesn't see those as links anyway, so it doesn't make any difference search engine wise. Like Rik says - just use relative links. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle
<jstucklex@attglobal.net> wrote: > Bruno Rafael Moreira de Barros wrote: >> On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote: >>> On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros >>> >>> <brunormbar...@gmail.com> wrote: >>>> 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;?> >>> Don't rely on short_tags, and especially not on <?=$var;?> syntax... >>> >>>> 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. >>> Unless there's an extra path not in your example, if in baseURL there >>> only >>> is a domain name, you can leave it out all together... >>> href="/css/site.css" will just get it relative from the root, which is >>> my >>> preferred method. >> Yeah but the problem is if my scripts are not deployed on the root.... >> It is really bad. > > If you're talking about using include(), require_once(), etc., that's a > different story. But the client doesn't see those as links anyway, so > it doesn't make any difference search engine wise. > > Like Rik says - just use relative links. It think he's looking for a 'just dump anywhere package' solution (so it may be in root but also on a different level). In which case, URLs in CSS stylesheets to images for instance are somewhat trickier. I'd say the most flexible solution for that is to use a simple PHP file as CSS augmenting the URL as needed. -- Rik Wasmus |
|
|||
|
On Apr 23, 12:23 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle > > > > <jstuck...@attglobal.net> wrote: > > Bruno Rafael Moreira de Barros wrote: > >> On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote: > >>> On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros > > >>> <brunormbar...@gmail.com> wrote: > >>>> 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;?> > >>> Don't rely on short_tags, and especially not on <?=$var;?> syntax.. > > >>>> 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. > >>> Unless there's an extra path not in your example, if in baseURL there > >>> only > >>> is a domain name, you can leave it out all together... > >>> href="/css/site.css" will just get it relative from the root, which is > >>> my > >>> preferred method. > >> Yeah but the problem is if my scripts are not deployed on the root... > >> It is really bad. > > > If you're talking about using include(), require_once(), etc., that's a > > different story. But the client doesn't see those as links anyway, so > > it doesn't make any difference search engine wise. > > > Like Rik says - just use relative links. > > It think he's looking for a 'just dump anywhere package' solution (so it > may be in root but also on a different level). In which case, URLs in CSS > stylesheets to images for instance are somewhat trickier. I'd say the most > flexible solution for that is to use a simple PHP file as CSS augmenting > the URL as needed. > -- > Rik Wasmus Precisely. I was just wondering if any of you knew of any solution that would solve that. Apparently, there isn't. I think having a PHP wrapper might be the way to go. I'll try it. |
|
|||
|
Rik Wasmus wrote:
> On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle > <jstucklex@attglobal.net> wrote: >> Bruno Rafael Moreira de Barros wrote: >>> On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote: >>>> On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros >>>> >>>> <brunormbar...@gmail.com> wrote: >>>>> 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;?> >>>> Don't rely on short_tags, and especially not on <?=$var;?> syntax.. >>>> >>>>> 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. >>>> Unless there's an extra path not in your example, if in baseURL >>>> there only >>>> is a domain name, you can leave it out all together... >>>> href="/css/site.css" will just get it relative from the root, which >>>> is my >>>> preferred method. >>> Yeah but the problem is if my scripts are not deployed on the root... >>> It is really bad. >> >> If you're talking about using include(), require_once(), etc., that's >> a different story. But the client doesn't see those as links anyway, >> so it doesn't make any difference search engine wise. >> >> Like Rik says - just use relative links. > > It think he's looking for a 'just dump anywhere package' solution (so it > may be in root but also on a different level). In which case, URLs in > CSS stylesheets to images for instance are somewhat trickier. I'd say > the most flexible solution for that is to use a simple PHP file as CSS > augmenting the URL as needed. You could be right - in which case your suggestion is the best. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
On Apr 23, 5:51*pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Rik Wasmus wrote: > > On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle > > <jstuck...@attglobal.net> wrote: > >> Bruno Rafael Moreira de Barros wrote: > >>> On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote: > >>>> On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros > > >>>> <brunormbar...@gmail.com> wrote: > >>>>> 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;?> > >>>> Don't rely on short_tags, and especially not on <?=$var;?> syntax.. > > >>>>> 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. > >>>> Unless there's an extra path not in your example, if in baseURL > >>>> there only > >>>> is a domain name, you can leave it out all together... > >>>> href="/css/site.css" will just get it relative from the root, which > >>>> is my > >>>> preferred method. > >>> *Yeah but the problem is if my scripts are not deployed on the root.... > >>> It is really bad. > > >> If you're talking about using include(), require_once(), etc., that's > >> a different story. *But the client doesn't see those as links anyway, > >> so it doesn't make any difference search engine wise. > > >> Like Rik says - just use relative links. > > > It think he's looking for a 'just dump anywhere package' solution (so it > > may be in root but also on a different level). In which case, URLs in > > CSS stylesheets to images for instance are somewhat trickier. I'd say > > the most flexible solution for that is to use a simple PHP file as CSS > > augmenting the URL as needed. > > You could be right - in which case your suggestion is the best. > > -- > ================== > Remove the "x" from my email address > Jerry Stuckle > JDS Computer Training Corp. > jstuck...@attglobal.net > ==================- Hide quoted text - > > - Show quoted text - I didn't understand how, but requests to my CSS and JS files with PHP have a really big response time, even in localhost. While the page I access has a response time of 70ms on localhost, my CSS and JS have around 300-500, sometimes they even go to 1000-2000. I don't understand that, because the CSS and JS is wrapped in the same way as the normal page, inside the framework. I really need a good PHP performance analyzer. |
|
|||
|
On Mon, 12 May 2008 11:57:57 +0200, Bruno Rafael Moreira de Barros
<brunormbarros@gmail.com> wrote: > On Apr 23, 5:51*pm, Jerry Stuckle <jstuck...@attglobal.net> wrote: >> Rik Wasmus wrote: >> > On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle >> > <jstuck...@attglobal.net> wrote: >> >> Bruno Rafael Moreira de Barros wrote: >> >>> On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote: >> >>>> On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros >> >> >>>> <brunormbar...@gmail.com> wrote: >> >>>>> 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;?> >> >>>> Don't rely on short_tags, and especially not on <?=$var;?> syntax.. >> >> >>>>> 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. >> >>>> Unless there's an extra path not in your example, if in baseURL >> >>>> there only >> >>>> is a domain name, you can leave it out all together... >> >>>> href="/css/site.css" will just get it relative from the root, which >> >>>> is my >> >>>> preferred method. >> >>> *Yeah but the problem is if my scripts are not deployed on the >> root... >> >>> It is really bad. >> >> >> If you're talking about using include(), require_once(), etc., that's >> >> a different story. *But the client doesn't see those as links anyway, >> >> so it doesn't make any difference search engine wise. >> >> >> Like Rik says - just use relative links. >> >> > It think he's looking for a 'just dump anywhere package' solution (so >> it >> > may be in root but also on a different level). In which case, URLs in >> > CSS stylesheets to images for instance are somewhat trickier. I'd say >> > the most flexible solution for that is to use a simple PHP file as CSS >> > augmenting the URL as needed. >> >> You could be right - in which case your suggestion is the best. > I didn't understand how, but requests to my CSS and JS files with PHP > have a really big response time, even in localhost. While the page I > access has a response time of 70ms on localhost, my CSS and JS have > around 300-500, sometimes they even go to 1000-2000. I don't > understand that, because the CSS and JS is wrapped in the same way as > the normal page, inside the framework. I really need a good PHP > performance analyzer. You could run xdebug and examine the output of the profiler. -- Rik Wasmus [SPAM] Now temporarily looking for some smaller PHP/MySQL projects/work to fund a self developed bigger project, mail me at rik at rwasmus.nl. [/SPAM] |
![]() |
| Thread Tools | |
| Display Modes | |
|
|