directories
I'm tired of having all my files under one folder. (It's getting confusing).
So, my question is...
Is it better to use ../../../index.html
or
websiteaddress.com/index.html
when using URLs.
I'd like to know which is the quickest and most efficient, and is using a lot of ../../../index.html bad.
Princess
disaster-master posted this at 23:14 — 1st November 2002.
She has: 2,154 posts
Joined: May 2001
You can really do this any way that works best for you. For example, if you have a site about web design and the URL is webdesign.com
The subjects on your site are HTML, CSS, javascript and contact page.
You can do the following:
webdesign.com/
webdesign.com/html/index.html
webdesign.com/css/index.html
webdesign.com/javascript/index.html
webdesign.com/contact/index.html
Princess4ubabe posted this at 23:46 — 1st November 2002.
They have: 25 posts
Joined: Nov 2002
Sorry, I didn't make myself very clear.
Say I'm on page webdesign.com/html/index.html and I want to include a picture on that page, but it's not in my "html" folder, it's in the main folder. Therefore, I'd have to use either
or
I'd like to use the ../../ concept, but it looks like I'll have to use a lot. Is that bad?
Megan posted this at 00:55 — 2nd November 2002.
She has: 11,421 posts
Joined: Jun 1999
No, not really. You could go either way, and it's debatable as to which method is best. Normally the ../ method is best, but sometimes a full URL is just easier, especially if you're using server generated includes for navigation.
Megan
Connect with us on Facebook!
Suzanne posted this at 02:23 — 2nd November 2002.
She has: 5,507 posts
Joined: Feb 2000
Actually, there are three options:
relative: ../images/whatever.gif
absolute: http://www.domain.com/images/whatever.gif
relative to root: /images/whatever.gif
On most servers, if you use the forward slash first, it means "go to the root and then follow this path", or in this case, go up to domain.com, then go to the images folder and get the whatever.gif.
Busy posted this at 02:35 — 2nd November 2002.
He has: 6,151 posts
Joined: May 2001
I remember reading ages ago using the full URL is bad for images etc, the server has to go out of your site then back in to get the image, where as using ../ or whatever the server only goes back or forwards within your sites space.
I suppose a few images wouldnt be bad but image intense sites does get slowed down a lil.
Also if people save your source, they can view your site with images off line, so you'd need .htaccess to pervent hot linking.
A good file system like disaster-master mentioned (without the index.html) is a good clean way to set them up, keep the .html files in the main directory, keep all images in a folder called "images" or "graphics" or something, javascript and CSS could go anywhere, don;t usually have many of them and what other files you have left in another folder.
Suzanne posted this at 03:11 — 2nd November 2002.
She has: 5,507 posts
Joined: Feb 2000
The full url is more work, yes. Relative to root isn't particularly different from relative, other than you have less ../../ to remember. And it works WAY better for CSS to use relative to root urls.
Blocking viewing images outside of the html page is excellent, so is blocking them being loaded from other urls, and you can also use .htaccess to set the index file for any folder, so it could be any file as the one that shows, including a "you cannot view these files" image, or better yet, either a redirect to the right place where they CAN view files, or a page with the site map on it, to help them get where they are going.
Princess4ubabe posted this at 16:39 — 4th November 2002.
They have: 25 posts
Joined: Nov 2002
Thanks everyone.
What is .htaccess?
ROB posted this at 18:48 — 4th November 2002.
They have: 447 posts
Joined: Oct 1999
also keep in mind that if you use absolute urls you cant move your site without editing every anchor,image and link in every page. it also increases the filesizes, and may (im not sure) cause a dns lookup for every page.
best to use relative urls. then you can just copy your site to anywhere and it will work fine with no modification.
dk01 posted this at 22:02 — 4th November 2002.
He has: 516 posts
Joined: Mar 2002
Same with relative to root also rob. I think thats what you mean but just to clarify.
-dk
jammin posted this at 22:58 — 4th November 2002.
They have: 222 posts
Joined: Sep 2002
hmm... i have always kept my html files in the main directory, any javascript or css in a subfolder, and another subfolder for images. seems to work for me... but then again it can get fairly cluttered if you have alot of html files.
anyone can do any amount of work provided it isnt the work they are supposed to be doing.
Renegade posted this at 00:58 — 5th November 2002.
He has: 3,022 posts
Joined: Oct 2002
yeah, i always find that relative is better, and eisier because less typing, faster to load, and lesstyping
hagar posted this at 00:59 — 5th November 2002.
They have: 104 posts
Joined: Oct 2002
i usually use one folder under root for includes, one under root for images, sub folders under includes for back end code, and point everything relative to root then into those folders to obtain my includes, images, javascript, WSH, whathaveyou.
When you have maybe 80+ subfolders just with content and documents in them(Like I often do), one place to aim your links at can help alot, especially if your domain name changes at all. Hardcoded domain links are usually a problem waiting to happen. ../../.. links can be an even bigger pain if your structure ever changes. Best to build around the concept that the site will be massive and use practices that make it easy to maintain, rather then think small, grow, and then weep over poor planning.
my $0.02 worth + Tax;)
"I ’ll make thee glorious by my pen, And famous by my sword." - James Graham, Marquess of Montrose (1612–1650)
Renegade posted this at 08:22 — 6th November 2002.
He has: 3,022 posts
Joined: Oct 2002
yeah good point hager, i've been down that road b4, now i use sub folders i.e css,js,images....
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.