?
Solved

Setting "Document Root"?  Is that the term

Posted on 2005-03-16
20
Medium Priority
?
205 Views
Last Modified: 2010-04-09
I have different pages on a website in different foldres (suprise!)

Anyway, I remember there was some code I could put in the header, I think that would set the root for the website so it would help me with the links.

Let's say the document root is (it's on an NT server):

C:\whatever\
and I have subfolders
c:\whaever\images\
C:\whatever\folder1\folder2\

And I have a file in folder2 that has an image in the whatever\image folder

I want to be able to reference that image folder no matter what folder and subfolder I may be in.

I'm sure I am overexplaing this, but hey!

Thanks

Rowby
0
Comment
Question by:Rowby Goren
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 4
  • +3
20 Comments
 
LVL 6

Expert Comment

by:benwiggy
ID: 13559051
<img src="../../bla.gif">
0
 
LVL 33

Assisted Solution

by:knightEknight
knightEknight earned 200 total points
ID: 13559062
do you mean this?  

<BASE HREF="http://www.mycompany.com/pages/">
0
 
LVL 6

Assisted Solution

by:benwiggy
benwiggy earned 200 total points
ID: 13559071
Just to clarify, "../" - means up a folder, "./" - means same folder, and "/" - means the root folder.
0
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 
LVL 32

Accepted Solution

by:
Batalf earned 800 total points
ID: 13559083
Start your links from the web root path. example:


<img src="/whatever/images/image.gif">


Another option could be the <base> tag, but that applies to all links(<img> <a>)

http://www.htmlcodetutorial.com/linking/_BASE.html





0
 
LVL 6

Expert Comment

by:benwiggy
ID: 13559084
Sorry - I meant  <img src="../../images/bla.gif">
0
 
LVL 6

Expert Comment

by:benwiggy
ID: 13559092
And as Batalf pointed out and as I said earlier - "/" first for root folder would be a good idea, they are alternative methods - both with their advantages and disadvantages...
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 13559095
Hi knightEknight

>>do you mean this? << 

<BASE HREF="http://www.mycompany.com/pages/">

Yes, that's what I mean.  But can it be without the http?

And., benwiggy, regarding
Just to clarify, "../" - means up a folder, "./" - means same folder, and "/" - means the root folder.

would "/" be the equivalent of base href?  Or at least work the same way?

Rowby
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 13559121
I should clarify.

I am dealing with a graphic navigation system that was set up to work fine in the root folder.  But the same pages were "saved as" to other folders, and because the links were not updated, they no longer link correctly to images and more importantly pages.

I would rather now redo the nav system so that is why I am looking for a simple shortcut to add sometihng to all of the headers that will resolve the "problem".

Also there are other just text links on these pages in the subfolders which no longer correctly link to the various pages.  So again, if "base href" can do the magic trick (or "/" will do the same thing, that will save me "hours" of recoding.

Thanks
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 13559134
correction to above comment"

I would rather now redo  should be "I would rather NOT redo"

HEE HEE
0
 
LVL 23

Assisted Solution

by:sciwriter
sciwriter earned 400 total points
ID: 13559389
Keep in mind, rowby -- everything is referenced to the folder you are in --
as long as you use this exact syntax --

images/myimg.gif

You do NOT want the leading slash before images for a good reason --
If you do, it will ALWAYS reference to the ROOT of the website
If you do not, the link is ALWAYS RELATIVE to where you are.

So as long as you make the image links --
imagefolder/imagename
You can move that HTML file to where ever you want --

www.mysite.com/section/subsection/index.html
Now if that index.html in the subsection folder needs to find its images,
as long as you use images/imagename
it will find it under --
www.mysite.com/section/subsection/images

It is WRONG to use -- /images/imagename
unless you always want to get images that are at the root.

One leading slash prohibits your site from being relative to whereever you want to put the files.
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 13559703
What if the web page is in this folder:

c:\root\subfolder1\subfolder2\webpage.html

and the image folder is in
c:\images\

Will " /images/imagename" find that image folder, even though it is "two folders down"  II assume your answer will be YES!" -- I just want to be sure.

0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 13559720
I guess I cannot use a variable of knightEknight's suggestion:

<BASE HREF="http://www.mycompany.com/pages/">

and call it

<BASE HREF="/">

?????

 
 
0
 
LVL 19

Expert Comment

by:webwoman
ID: 13560263
>> What if the web page is in this folder:

c:\root\subfolder1\subfolder2\webpage.html

and the image folder is in
c:\images\

Will " /images/imagename" find that image folder, even though it is "two folders down"  II assume your answer will be YES!" -- I just want to be sure.>>

No. Absolutely not. You CANNOT have ANYTHING outside of the WEB root. The web root is the default directory that your web server is set to use. If you have images OUTSIDE of that, there is no real way to access them, unless you're going to make everything server side scripts and go through contortions.

You need to put your images IN the web, not OUTSIDE of it. Then you can use the leading slash (/) to start the search for the file from the web ROOT.

So if your images were in
c:\root\images
you would ALWAYS, from any place in the site, reference them by
/images/imagename
0
 
LVL 19

Assisted Solution

by:webwoman
webwoman earned 400 total points
ID: 13560331
Just so it's clear -- there is NO magic bullet here. You ARE going to have to recode, no matter WHAT you do. Might as well do it right.

I use /folder/file on all my includes, and it works fine.

Base href causes WAY more problems than it solves -- it will be applied to EVERY link, whether internal, external, right or wrong.
0
 
LVL 23

Expert Comment

by:sciwriter
ID: 13560351
well, you are dealing with web servers here, not your c drive -- so ---

Root of server = =   /mylogin/public_html

if you did  -- find --  /goofy.jpg
goofy.jpg would HAVE to be in the Public_html directory (the root of your website) -- else it would NOT be found.

so Say you have these --

index.html
image.jpg
/images/nuther.jpg
/subfolder/index2.html
/subfolder/images/homey.gif

and you are in /subfolder/index2.html  --  this is the page we are trying to find things from.

This is how you would get to EVERYTHING above -- from index2.html --

images/homey.gif
/index.html
/images/nuther.jpg

You see that YES, you can reference everything you want from anywhere you want, just remember this --

/  -- a leading forward slash means, it is relative to the ROOT of the WEBSITE (try to forget C:\ here)
[___ blank] (i.e. nothing)  then index2.html references the Current file -- index2.html

and [___ Blank] images/image.gif  references the image in the image directory UNDER (relative to) where you are.

This needs to be as clear as pea soup before you leave this thread....
0
 
LVL 23

Expert Comment

by:sciwriter
ID: 13560369
sorry, my complete reference list above refers to your question, rowby, I didn't see the intervening comments.
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 13560433
Hi webwoman:

>> So if your images were in
c:\root\images
you would ALWAYS, from any place in the site, reference them by
/images/imagename  <<


I think your comments "says it all" and I will use that rather than the base thingie.

Thanks everyone.  I'll leave this question open for 24 hours in case there are any other comments.

(Points will be spilt appropriately!)

Rowby
0
 
LVL 23

Expert Comment

by:sciwriter
ID: 13560660
<< You CANNOT have ANYTHING outside of the WEB root.>>

Not true -- all of CGI is outside the webroot, as are other declared and decalrable files and directories...
0
 
LVL 19

Expert Comment

by:webwoman
ID: 13561373
Not necessarily. Most shared servers will NOT have your CGI/server side files outside of YOUR web root. You might set up your server that way, but it's certainly not required. And in many cases, it's not even advisable.

The perl/PHP COMPILERS would be outside the web root, but those are shared by everybody who uses perl/PHP. ASP dlls would also be outside the web root, for the same reason.

But YOUR files are NOT normally outside the web root.
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 13569406
Thanks everyone.

Your comments clarified everything and I ending up using the "/root" solution.  

What would I do without Experts Exchange (and Find & Replace)

Rowby
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question