473,788 Members | 2,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($reques ted_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.
Jun 2 '08 #1
8 2123
On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros
<br***********@ gmail.comwrote:
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
Jun 2 '08 #2
On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros

<brunormbar...@ gmail.comwrote:
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.
Jun 2 '08 #3
Bruno Rafael Moreira de Barros wrote:
On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
>On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros

<brunormbar... @gmail.comwrote :
>>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.
js*******@attgl obal.net
=============== ===

Jun 2 '08 #4
On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle
<js*******@attg lobal.netwrote:
Bruno Rafael Moreira de Barros wrote:
>On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
>>On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros

<brunormbar.. .@gmail.comwrot e:
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
possibilit y, 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
Jun 2 '08 #5
On Apr 23, 12:23 pm, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle

<jstuck...@attg lobal.netwrote:
Bruno Rafael Moreira de Barros wrote:
On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros
><brunormbar... @gmail.comwrote :
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.
Jun 2 '08 #6
Rik Wasmus wrote:
On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle
<js*******@attg lobal.netwrote:
>Bruno Rafael Moreira de Barros wrote:
>>On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros

<brunormbar. ..@gmail.comwro te:
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.
js*******@attgl obal.net
=============== ===

Jun 2 '08 #7
On Apr 23, 5:51*pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
Rik Wasmus wrote:
On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle
<jstuck...@attg lobal.netwrote:
Bruno Rafael Moreira de Barros wrote:
On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros
>><brunormbar.. .@gmail.comwrot e:
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
possibilit y, 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...@attgl obal.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.
Jun 2 '08 #8
On Mon, 12 May 2008 11:57:57 +0200, Bruno Rafael Moreira de Barros
<br***********@ gmail.comwrote:
On Apr 23, 5:51*pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>Rik Wasmus wrote:
On Wed, 23 Apr 2008 12:34:01 +0200, Jerry Stuckle
<jstuck...@attg lobal.netwrote:
Bruno Rafael Moreira de Barros wrote:
On Apr 22, 8:16 pm, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Tue, 22 Apr 2008 21:01:13 +0200, Bruno Rafael Moreira de Barros
>>><brunormbar. ..@gmail.comwro te:
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]
Jun 2 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3425
by: phpkid | last post by:
Howdy I've been given conflicting answers about search engines picking up urls like: http://mysite.com/index.php?var1=1&var2=2&var3=3 Do search engines pick up these urls? I've been considering converting a site of mine to PHP-Nuke, but if the individual modules aren't picked up in search engines I'm not going to do it. Thanks phpKid
0
4156
by: R. Rajesh Jeba Anbiah | last post by:
Q: Is PHP search engine friendly? Q: Will search engine spiders crawl my PHP pages? A: Spiders should crawl anything provided they're accessible. Since, nowadays most of the websites are been developed with PHP, you are not supposed to doubt that. As a proof that PHP pages could be crawled and indexed, refer this Google search
0
1207
by: Shabam | last post by:
I'm interested in converting dynamic urls to something that looks static so that they're more search engine friendly. Instead of www.domain.com/script.aspx?userid=1234 I'd like to have it as www.domain.com/1234.html. How can this be done via code?
4
1957
by: moondaddy | last post by:
I've made the decision to use search engine friendly URLs in my site which means translating stripping all parameters our of the URL and converting it to a hierarchical URL like this: Change: /mysite/default.aspx?MenuID=contactus To: /mysite/ContactUs.aspx? The problem I'm having is that its really slowed things up by at least 0.5 seconds to 1 second longer just to pull up a light weight static page. The
5
2069
by: Sam | last post by:
Does anyone know of a way to create a search page under ASP.NET 2.0? I have started out by configuring a catalog in Index Server, registering the aspx, ascx extensions in the registry to allow them to be indexed and built the catalog as per KB article, but I've run into an interesting problem. When you publish a website from Whidbey, it precompiles everything and strips out the searchable details of the page (metadata, html, etc)...
2
1382
by: | last post by:
Apache has a look-back feature that lets it scan back down the URL if it doesn't find what it is looking for. For example: http://www.domain.com/article.php/999/12 In this above case there is no directory or file called 12, so it looks at 999. There is no directory or file called 999 so Apache looks down the URL and sees article.php, which does exist, and calls up that script. Apache also has a global variable called $PATH_INFO that is...
2
6547
by: David | last post by:
Sent this to alt.php a couple of days back, but doesn't look like I'll get an answer, so trying here. I'm trying to convert a script to use friendly URLs, I've done this before, but my PHP skills are quite basic so far, far from proficient at this. ..htaccess file- DirectoryIndex default.php index.asp index.html index.htm index.php
4
1600
by: Geoff Berrow | last post by:
I've been trying to use .htaccess to get Apache to recognise 'article' as 'article.php' so I can have search engine friendly urls in the form article/var1/var2/var3 etc I have this in a .htaccess file <Files article> ForceType application/x-httpd-php </Files>
8
2143
by: Roman | last post by:
I received a marketing call from a guy first showing me my website and then some other website and ranking of that other website. My questions is it worth paying to SEO corporation a $1200 - $3000 setup fee and then $150 monthly to get your website search optimized ? I used the domaintools.com and it seems like my website had higher SEO rating and tag relevance than the example site he was showing me. I did not pay attention to search...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10364
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.