Setting "Document Root"? Is that the term

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
LVL 9
Rowby GorenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

benwiggyCommented:
<img src="../../bla.gif">
0
knightEknightCommented:
do you mean this?  

<BASE HREF="http://www.mycompany.com/pages/">
0
benwiggyCommented:
Just to clarify, "../" - means up a folder, "./" - means same folder, and "/" - means the root folder.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

BatalfCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
benwiggyCommented:
Sorry - I meant  <img src="../../images/bla.gif">
0
benwiggyCommented:
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
Rowby GorenAuthor Commented:
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
Rowby GorenAuthor Commented:
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
Rowby GorenAuthor Commented:
correction to above comment"

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

HEE HEE
0
sciwriterCommented:
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
Rowby GorenAuthor Commented:
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
Rowby GorenAuthor Commented:
I guess I cannot use a variable of knightEknight's suggestion:

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

and call it

<BASE HREF="/">

?????

 
 
0
webwomanCommented:
>> 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
webwomanCommented:
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
sciwriterCommented:
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
sciwriterCommented:
sorry, my complete reference list above refers to your question, rowby, I didn't see the intervening comments.
0
Rowby GorenAuthor Commented:
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
sciwriterCommented:
<< 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
webwomanCommented:
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
Rowby GorenAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.