Forum Moderators: open
But I'm curious if anyone knows of any other compelling reason NOT to code absolute paths into href attributes for links on-site?
Aside from absolute paths being cumbersome and unnecessary, is it OKAY to use them in href attributes, or does it cause some hidden problems with (a)site navigation, (b)server load, or (c)search engines?
I'm working on a php script that may require absolute hrefs, so it's raised this question that I've never had to think about before...
Thanks for any insight you may have.
cEM
From what I've read around here, just about the only advantage of relative over absolute is the ease of development. You can copy the files from your local machine to the server without needing any changes.
I've been using relative for that reason, but I'm going to switch over to absolute as soon as I figure out how to set up my Powerbook as a server, and figure out the Apache configuration to let me use the full URL locally.
Why? The impression is that absolute URLs do slightly better in the SEs (allegedly GoogleGuy recommends them, but I can't find the post), and it just makes it a little bit harder for a casual/lazy thief to steal my content (Yes, I'm flattering myself :) ). Plus I'm aware of no downsides to using absolutes.
That sounds like you are just browsing your hard-drive from folder to folder.
If you want to use absolute URLs; counted from the root (like /folder/folder/file.html for example) then install Apache, or PHPdev (which includes Apache) then you can browse the local copy of your site by typing http://localhost/ or http://127.0.0.1/ instead.
Some of us are dumber than others; it took me quite a while to figure this out.... *sigh* I do believe that I'd go farther with all of this had I started 30 years younger!
Then, you can set Apache up to serving test.website.tld
No problem with this process. I'm using this to develop about five websites served locally from TiBook using Apache 2 from ServerLogistics and virtual hosting. Works like a charm.
You might be interested in taking a look at my homepage (URL in profile)
Probably mentioned in that thread is the matter of request fulfillment time.
Absolute URLs need to resolve the domain.
Relative URLs do not need to.
For this reason, it is a (very slightly) faster browsing experience for the visitor when you use relative URLs. I would definitely recommend using relative URLs for page content (images, etc.), but you'll have to decide for yourself what to do when linking from one of your pages to another.
I can see the argument for using absolute URLs to gain a SERPS advantage, as when the context of the spidered URL is supported not only by the domain but reinforced by the code it may add extra weight to the links. However this is purely conjecture. I have no idea how the SEs really use such information within a single domain.
dev.example.tld
and
www.example.tld
I do dev work on the dev version of the site, then deploy to the live version. Using absolute paths makes that almost impossible. For things like external apps then need an absolute path (bb, gallery, blog, etc), I've been using server side variables and it's been working quite well.
For example:
ASP:
http: //<%=Request.ServerVariables("SERVER_NAME")%>/somepage/onmy/site.html
or PHP:
http: //<? echo $_SERVER['SERVER_NAME']?>/somepage/onmy/site.html
So may I try YOUR version, see if I can figure it out? If so, and I can't, y'know I'll be back.... bad penny time....