Web site directory lay out

Associate
Joined
18 Oct 2002
Posts
710
Location
Somerset
Hi

I am putting together a few web pages and am currently running around in circles with the directory and page layout on the server.

My main page is in the root www folder and called index.html
There is then the default.css file

From that main page there are links to different category's.

I was looking at creating folders inside the root www folder for each category, then put a copy of the index.html and default.css file into each of these directorys and editing the index.html file to fit as a new main page for each category.

The problem i have run into is that there is an img folder inside the root www that the css file points to /img/name.gif etc etc

the files copyed to the category folders can not make sense of this, so i edited on to read www/img/name.gif but this did not work.

Is there an easy way to re use the index and css files across multiple folders?
Am i heading in the right direction? or doing it all wrong? should all my category main pages be in the root folder rather than there own folder?

Thanks
Keith
 
you can set your pathes as static url's rather than by directory,

for example:

<img src="http://www.yoursitename.com/img/yourimage.gif" width="***" height="***" />

hope this helps,


Also just worked out that i can change the href in each index page tha points at the css file so only one is needed in the root :rolleyes:

The problem i am having with that is that my links to this point have all been with out the http://mydomain.co.uk part at the front,
The browser viewing the site puts this in its self as i understand it?
this has enabled me to have links that work from the out side world, but also give me a site that i can use from inside my lan as while i am inside it replaces http://mydomain.co.uk with http://localhost,

Unfortunately i can only make this work when it refers to pages in the same directory or a directory deeper and not a directory back towards the root.

I wanted to do full urls every where and find another way around using the site inside my lan, but the method i thought i could use will not work.

I thought i could add something along the lines of

XXX.XXX.X.XXX http://mydomain.co.uk

to the hosts file in

c:windows/system32/drivers/etc

with XXX.etc being the internal IP of my web server.

But this is not working and using my domain name inside the lan takes me to my router login page. :(
 
Well i have now managed to edit my host file and make it work so now the site can have full url links all over and will still work inside my lan as well :D
 
You could make use of relative paths properly,

a preceding / means from the root of your server
without a preceding / means from the current directory

eg, a file www/content/hello.html can include /index.css which comes from www/index.css but if it includes index.css it tries to include www/content/index.css

Hard coding full server URLs is bad practice and should be avoided at all costs.

You can also use .. (double dot) to traverse up the directory structure eg

www/content/hello.html can include ../index.css which is www/index.css as you are in the directory 'content' and use .. to go up one to www/

Sub-directories are generally reserved for significantly different areas of the site - or minisites etc.

Both of the sites i've written - www.irisradar.com and www.lewty.org.uk are entirely held off one index.php, the page linked to defines which set of content to load from the database plus there is a /css and a /images for the styling.

This single page structure works brilliantly and when i had to migrate it to a new server it took me a total of 20 minutes, keep any data that is common between files in a single location: one place to edit when it needs to be updated.
 
Last edited:
Hard coding full server URLs is bad practice and should be avoided at all costs.

was not aware of that :o will have to alter things again :)

I was going down the sub directory route so every subject had its own index page, but i suppose that was just for me and isn't needed, also thought it would be easier to keep track of what belongs to what section if it is split across sub directories.

I now have all index pages using the 1 css file and set of images so a step in the right direction,

I think i will stick with the sub directory method but go back over my links again and un-hard code them.

Thanks for the post, very informative.
 
Back
Top Bottom