[Hyperlinks] Relative or Full Paths?

Soldato
Joined
2 Jun 2004
Posts
18,423
Conrad11 said:
Hi there,

When people are doing hyperlinks do they use relative or full paths?

Any advantage of either?

Thanks.
advantage of full links is google might pick them up as references. happened to my old site and resulted in a higher google rating! :D

but i generally use relative on my newest site.
 
Soldato
OP
Joined
12 Jun 2005
Posts
5,361
Craig321 said:
Advantage of relative paths is you can move the script around without worrying about links.

Surely that is irrelivant, cause you would have to change the links anyways if you move it?
 
Soldato
Joined
3 Aug 2005
Posts
4,534
Location
UK
Conrad11 said:
Surely that is irrelivant, cause you would have to change the links anyways if you move it?
No. A lot of people tend to (whether this is good practice or not, I have no idea) set a global variable as the document root (e.g. www.websitename.com/applicationname/) then use relative URLs within the application itself. That way all one has to do when moving the application around is redefine the global document root variable.

I tend to use relative URLs, then play around with CSS2 (I think it is) to display absolute URLs in print-outs :)
 
Man of Honour
Joined
31 Jan 2004
Posts
16,335
Location
Plymouth
Al Vallario said:
No. A lot of people tend to (whether this is good practice or not, I have no idea) set a global variable as the document root (e.g. www.websitename.com/applicationname/) then use relative URLs within the application itself. That way all one has to do when moving the application around is redefine the global document root variable.
I do a slightly modified version of this :)
 
Soldato
Joined
2 May 2004
Posts
19,950
Conrad11 said:
Surely that is irrelivant, cause you would have to change the links anyways if you move it?

No, if you code it so you don't need to change the URLs then you won't have to.

e.g.

Code:
$include "includes/hello.php";

When you move the script this will not need to be re-coded, if you used this:

Code:
$include "http://www.blah.com/includes/hello.php";

The above would need to be recoded.
---------------------------------------------------
A better example:

Code:
<a href="index.php">Home</a>

Wouldn't need to be recoded but this would:

Code:
<a href="http://www.site.com/index.php">Home</a>
 
Back
Top Bottom