Links, what is the best way.....

They have: 93 posts

Joined: Dec 2001

Hi,
what is the best/correct way to put links on a site ?
Should I use links like /page,html or /path/to/page.html or the whole http://www.site.com/page.html?
What is the difference between these ? & does any style of link slow down page loading ?

Mika

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Normally you should use a relative path. However, if you're using SSI it may be better to use the whole path in your includes depending on how your server's set up.

Brian Farkas's picture

They have: 1,015 posts

Joined: Apr 1999

As Megan mentioned, it's better to use relative links instead of the entire URL. That way, if someone accesses your site in the form of http://domain.com/ they will not be brought to domain.com when they click a link.

Neither style, however, slows down page loading any more than the other.

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

Quote: Originally posted by Brian Farkas

Neither style, however, slows down page loading any more than the other.

The fastest way is always:
page.html but this only works if you don't use sub-directories.
/page.html is slower but not perceptibly so.
http://www.sitename.com/page.html is quite a bit slower than the above and should only be used in stuff like html emails.

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

Brian Farkas's picture

They have: 1,015 posts

Joined: Apr 1999

Really? Hmm.. didn't know that. Where did you hear that from? I wouldn't have thought that just a few extra characters of text would have significantly affected page loading at all. I guess you learn something new each day.

Brian

Busy's picture

He has: 6,151 posts

Joined: May 2001

If you use the full path, say on images, the browser actually goes out of your directory/domain and comes back in for each full pathed object listed, but if you only have the image name it knows they are all within your directory.

They have: 93 posts

Joined: Dec 2001

The problem that I have at the moment is using SSI on all my pages to call 1 menu, and I am also using the same menu in sub-domains, so ../index.html from a sub-domain results in a page not found, as a result I have used http://www.domain.com/ as links for all the pages in my menu.
Is this a good/bad thing ?
Any other Ideas Suggestions ?

Thanks

Mika

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

You might have to use full URL's just in your includes to make sure everything references properly.

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

Leave the .. out of ../ so that it is /
Using ../ forces it up one level, using / forces it to read from your document root of the server which is where the index page is.

Brian, as far as where I heard about the difference between using sitename.com/pagename.html as opposed to /pagename.html . , who knows where I read that. It just comes from practice. Using the full path causes the server to first find sitename.com, then index.html. Using /index.html, causes it to only use the path from the server that it is on. Several other factors come into play. One is your cache. If the link is already loaded is in you cache, the speed difference will not be as great.

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

They have: 93 posts

Joined: Dec 2001

but if I

Quote: Leave the .. out of ../ so that it is /

in my menu doesn't make any difference as when the user has navigated to one of my sub-domains the /page.html reads from the document root of the sub-domain means that they get a page not found, unless I duplicate my site in each sub-domain.
SO for now I guess it has to be http://www.....

Mika

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

Oops, I really didn't see the part about sub-domains, which have their own docroot. You could specify the full path to the menu, like so /home/username/public_html/menu.html.

I personally don't use SSI. I prefer just to use includes in PHP.

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

They have: 5,633 posts

Joined: Jan 1970

Cant you just use ".\file.php"

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.