This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Webmaster forum > February 2007 > Apache/Windows question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Apache/Windows question
TexasLover

2007-02-23, 6:17 pm

I posted this yesterday morning to comp.infosystems.www.servers.unix
and thought I would also try here since I haven't seen a response.


On my remote server, let's say my home page is here:

/htdocs/index.html

There is a subfolder called images, so if I have a web page at
/htdocs/contact/index.html, it can reference a file in the images
folder like this:

/images/contact.jpg

This fails on my local Apache test server, how do I make this work?
Thanks.

Marc Bissonnette

2007-02-23, 6:17 pm

TexasLover <tex@slover> altered the spacetime fabric by disgorging
news:bnmut2l2ibdl1p27s74s6lua8po5v20fji@4ax.com:

> I posted this yesterday morning to comp.infosystems.www.servers.unix
> and thought I would also try here since I haven't seen a response.
>
>
> On my remote server, let's say my home page is here:
>
> /htdocs/index.html
>
> There is a subfolder called images, so if I have a web page at
> /htdocs/contact/index.html, it can reference a file in the images
> folder like this:
>
> /images/contact.jpg
>
> This fails on my local Apache test server, how do I make this work?
> Thanks.


Have you double checked that the image ref is indeed

<IMG SRC="/images/contact.jpg">

and not

<IMG SRC="images/contact.jpg">

Also, do you have a <BASE HREF= tag set ?
If so, what is it set to ? That may be your problem, if the first example
isn't: If your BASE HREF is set to http://www.yoursite.com/contact/ and you
reference /images/, the browser thinks you are pointing to
http://www.yoursite.com/contact/images/contact.jpg

since the point of the BASE HREF is to set the root reference for non-
absolute URLs and filerefs. The BASE HREF is usually handy for CGI-
generated pages that are pulling in templates or includes that are also
used elsewhere in non-generated sections of the site ('cuz without it, the
browser will think a reference to 'images/foo.jpg' is actually
http://www.yoursite.com/cgi-bin/images/foo.jpg' - which usually doesn't
exist, or isn't accessible if your server is properly set up)

HTH



--
Marc Bissonnette
Looking for a new ISP? http://www.canadianisp.com
Largest ISP comparison site across Canada.
John Hosking

2007-02-23, 6:17 pm

TexasLover wrote:

some things which confused me slightly...

> On my remote server, let's say my home page is here:
>
> /htdocs/index.html


Okay, I'm *still* with you.

>
> There is a subfolder called images,


Subfolder? Do you mean /htdocs/images?

> so if I have a web page at
> /htdocs/contact/index.html,


Hey, wait a minute; what happened to /htdocs/index.html?

> it can reference a file in the images
> folder like this:
>
> /images/contact.jpg


From within /htdocs/contact/index.html you should be able to "access"
/htdocs/images/contact.jpg by using "../images/contact.jpg". Test
carefully to be sure; I'm more of a Windows guy :-( (Watch especially
for leading slashes, or not, and the *direction* of all the slashing).
And anyway, I may well have misunderstood your goals. See Marc's answer
first; he's likely to actually know what he's talking about.

From within /htdocs/index.html (the page you mentioned first but then
forgot about) you should be able to "access" /htdocs/images/contact.jpg
by using "images/contact.jpg".

--
John
TexasLover

2007-02-23, 10:16 pm

On Fri, 23 Feb 2007 15:58:38 -0600, Marc Bissonnette
<dragnet\_@_/internalysis.com> wrote:

>Have you double checked that the image ref is indeed
>
><IMG SRC="/images/contact.jpg">
>
>and not
>
><IMG SRC="images/contact.jpg">


Yes, definitely.

>Also, do you have a <BASE HREF= tag set ?


This would be in a page, correct? There is none.

>If so, what is it set to ? That may be your problem, if the first example
>isn't: If your BASE HREF is set to http://www.yoursite.com/contact/ and you
>reference /images/, the browser thinks you are pointing to
>http://www.yoursite.com/contact/images/contact.jpg


On the remote server, /images/file.jpg points to where it should, but
fails locally even though the test site is in the root directory as
defined ny http.conf

>since the point of the BASE HREF is to set the root reference for non-
>absolute URLs and filerefs. The BASE HREF is usually handy for CGI-
>generated pages that are pulling in templates or includes that are also
>used elsewhere in non-generated sections of the site ('cuz without it, the
>browser will think a reference to 'images/foo.jpg' is actually
>http://www.yoursite.com/cgi-bin/images/foo.jpg' - which usually doesn't
>exist, or isn't accessible if your server is properly set up)
>
>HTH


So do I need to add this BASE HREF to my pages if I want to reference
things this way locally? THanks.
TexasLover

2007-02-23, 10:16 pm

On Fri, 23 Feb 2007 23:14:57 +0100, John Hosking
<John@DELETE.Hosking.name.INVALID> wrote:

>TexasLover wrote:
>
>some things which confused me slightly...
>
>
>Okay, I'm *still* with you.
>
>
>Subfolder? Do you mean /htdocs/images?


Yes, exactly.
>
>
>Hey, wait a minute; what happened to /htdocs/index.html?
>

That index.html is in the root, now I was talking about an index.html
in a contact folder.

>
> From within /htdocs/contact/index.html you should be able to "access"
>/htdocs/images/contact.jpg by using "../images/contact.jpg". Test
>carefully to be sure; I'm more of a Windows guy :-( (Watch especially
>for leading slashes, or not, and the *direction* of all the slashing).
>And anyway, I may well have misunderstood your goals. See Marc's answer
>first; he's likely to actually know what he's talking about.


Thanks, I know I can use ../ to go up a level, but sometimes I want to
use includes that are all in one folder, in which case I want to
reference a file by saying where it is relative to root rather than
pointing to it via ../. That will become inaccurate as I have deeper
into folder levels. Thanks.
> From within /htdocs/index.html (the page you mentioned first but then
>forgot about) you should be able to "access" /htdocs/images/contact.jpg
>by using "images/contact.jpg".


Marc Bissonnette

2007-02-23, 10:16 pm

TexasLover <tex@slover> altered the spacetime fabric by disgorging
news:ad2vt29tmdh6a0pj69nlqlv8fh8ntreem6@4ax.com:

> On Fri, 23 Feb 2007 15:58:38 -0600, Marc Bissonnette
> <dragnet\_@_/internalysis.com> wrote:
>
>
> Yes, definitely.
>
>
> This would be in a page, correct? There is none.
>
>
> On the remote server, /images/file.jpg points to where it should, but
> fails locally even though the test site is in the root directory as
> defined ny http.conf
>
>
> So do I need to add this BASE HREF to my pages if I want to reference
> things this way locally? THanks.


Well, you shouldn't have to, unless the page you are serving is being
generated dynamically from another location, which it doesn't sound like
it is.

Can you give us a URL to take a peek at the source of ?

I've posted two examples:

http://www.canadianisp.com/awwtest.html

and

http://www.canadianisp.com/subfolder/

replicating what my understanding of what you're doing is.

In neither example am I using a <BASE HREF> because it shouldn't be
necessary.

Just for the sake of completeness, here's my httpd.conf entry for
canadianisp.com:

<VirtualHost 198.104.136.18>
ServerAdmin marc@canadianisp.com
DocumentRoot /var/www/sites/canadianisp.com/htdocs
ServerName canadianisp.com
ServerAlias www.canadianisp.com
ScriptAlias /cgi-bin/ "/var/www/sites/canadianisp.com/htdocs/cgi-
bin/"
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-
Agent}i\"" combined
ErrorLog logs/canadianisp_error.log
CustomLog logs/canadianisp_access.log combined
</VirtualHost>

--
Marc Bissonnette
Looking for a new ISP? http://www.canadianisp.com
Largest ISP comparison site across Canada.
TexasLover

2007-02-25, 6:16 pm

On Sat, 24 Feb 2007 17:06:51 -0600, Marc Bissonnette
<dragnet\_@_/internalysis.com> wrote:


>Try the solution from before with the DocumentRoot being set to
>J:/webs/ASC2/public_html/ - It's obviously not seeing the same root
>directory that you think it should :)


I had to shut down last night, we haed major storms.

I tried your suggestion two ways:

I did just what you suggested. Of course, the site is in J:/webs/ASC2,
so I see "Not Found."

I then created the folder, J:/webs/ASC2/public_html/, and moved the
site there. The site works again, but the problem persists.

Let me ask you something, Marc:

If I call http://localhost/ and see the index.php I expect to see, I
am definitely seeing the root of DocumentRoot, correct? You see, I
have 35 entries under DocumentRoot like this:

# DocumentRoot "J:/webs/_null"
DocumentRoot "J:/webs/ASC2"
# DocumentRoot "J:/webs/DigiMusic2"
# DocumentRoot "J:/webs/DigiMusic3"
# DocumentRoot "J:/webs/JulianaNEW"
# DocumentRoot "J:/webs/jimmyw"
# DocumentRoot "J:/webs/Kontik"
# DocumentRoot "J:/webs/LarryCrow"
# DocumentRoot "J:/webs/nixonsite"
# DocumentRoot "J:/webs/KarenPendle"
# DocumentRoot "J:/webs/OceanFX"
# DocumentRoot "J:/webs/ParaSong"
# DocumentRoot "J:/webs/TheSoldier"
# DocumentRoot "J:/webs/TonyCarter"
etc.

In any give day, I uncomment one of them at a time, restart Apache,
work on that site, upload changes, then move onto the next site.

I'm wondering if you thought that I was confused/wrong about where my
files were (which is entreily possible, I make mistakes regularly) or
whether Apache has some built-in reference to "public_html" that I
can't see in httpd.conf.

Thanks.
TexasLover

2007-02-25, 6:16 pm

There are now downloads at the bottm of http://www.middletenn.com/
Marc Bissonnette

2007-02-25, 6:16 pm

TexasLover <tex@slover> altered the spacetime fabric by disgorging
news:ss23u2lpshfrb4oaret43mrdg75pjiumv1@4ax.com:

> On Sat, 24 Feb 2007 17:06:51 -0600, Marc Bissonnette
> <dragnet\_@_/internalysis.com> wrote:
>
>
>
> I had to shut down last night, we haed major storms.
>
> I tried your suggestion two ways:
>
> I did just what you suggested. Of course, the site is in J:/webs/ASC2,
> so I see "Not Found."
>
> I then created the folder, J:/webs/ASC2/public_html/, and moved the
> site there. The site works again, but the problem persists.
>
> Let me ask you something, Marc:
>
> If I call http://localhost/ and see the index.php I expect to see, I
> am definitely seeing the root of DocumentRoot, correct? You see, I
> have 35 entries under DocumentRoot like this:
>
> # DocumentRoot "J:/webs/_null"
> DocumentRoot "J:/webs/ASC2"
> # DocumentRoot "J:/webs/DigiMusic2"
> # DocumentRoot "J:/webs/DigiMusic3"
> # DocumentRoot "J:/webs/JulianaNEW"
> # DocumentRoot "J:/webs/jimmyw"
> # DocumentRoot "J:/webs/Kontik"
> # DocumentRoot "J:/webs/LarryCrow"
> # DocumentRoot "J:/webs/nixonsite"
> # DocumentRoot "J:/webs/KarenPendle"
> # DocumentRoot "J:/webs/OceanFX"
> # DocumentRoot "J:/webs/ParaSong"
> # DocumentRoot "J:/webs/TheSoldier"
> # DocumentRoot "J:/webs/TonyCarter"
> etc.
>
> In any give day, I uncomment one of them at a time, restart Apache,
> work on that site, upload changes, then move onto the next site.
>
> I'm wondering if you thought that I was confused/wrong about where my
> files were (which is entreily possible, I make mistakes regularly) or
> whether Apache has some built-in reference to "public_html" that I
> can't see in httpd.conf.


Nah, the DocumentRoot statement should be it as far as I know - I was
making the assumption at first (I know, assumptions, bad thing) that you
had your file structure replicated on your local machine and had simply
forgotten to move the dir to /public_html/. For example, on my server,
the doc root for canadianisp.comis /var/www/sites/canadianisp.com/htdocs/
so on my windows machine, it's nearly duplicated:
C:/internetdata/var/www/sites/canadianisp.com/htdocs/

Arg. I grabbed your zip files and played around with them. Keeping in
mind, I'm not running a server, so I was just viewing them from within
Opera, but screwing around with the base href. It doesn't behave anything
like it should when the same file is hosted on a *nix system.

I'm wondering if, on a local windows system, <BASE HREF> is completely
ignored - I tried in both Opera and MSIE to get a base href to modify the
relative root of a document, but in many iterations of the files, it was
all ignored a preceding slash, in my case, was always interpreted as C:\
not matter what was in the BASE HREF variable.

Perhaps, it would be easiest for you to set up a DYNDNS account and have
a domain (or simply your dynamic IP) pointing to your home machine so
that localhost simply wouldn't be an issue.

Or install linux :) :) :)

I'm completely stumped, even after googling for
"base href"+windows+localhost

none of the examples within those results actually modifies the base root
:(

--
Marc Bissonnette
Looking for a new ISP? http://www.canadianisp.com
Largest ISP comparison site across Canada.
TexasLover

2007-02-25, 6:16 pm

On Sun, 25 Feb 2007 10:19:51 -0600, Marc Bissonnette
<dragnet\_@_/internalysis.com> wrote:

>TexasLover <tex@slover> altered the spacetime fabric by disgorging
>news:ss23u2lpshfrb4oaret43mrdg75pjiumv1@4ax.com:


<snip>

>
>Nah, the DocumentRoot statement should be it as far as I know - I was
>making the assumption at first (I know, assumptions, bad thing) that you
>had your file structure replicated on your local machine and had simply
>forgotten to move the dir to /public_html/. For example, on my server,
>the doc root for canadianisp.comis /var/www/sites/canadianisp.com/htdocs/
>so on my windows machine, it's nearly duplicated:
>C:/internetdata/var/www/sites/canadianisp.com/htdocs/
>
>Arg. I grabbed your zip files and played around with them. Keeping in
>mind, I'm not running a server, so I was just viewing them from within
>Opera, but screwing around with the base href. It doesn't behave anything
>like it should when the same file is hosted on a *nix system.
>
>I'm wondering if, on a local windows system, <BASE HREF> is completely
>ignored - I tried in both Opera and MSIE to get a base href to modify the
>relative root of a document, but in many iterations of the files, it was
>all ignored a preceding slash, in my case, was always interpreted as C:\
>not matter what was in the BASE HREF variable.


That's right, on a Windows box, root means the root of the drive.

>Perhaps, it would be easiest for you to set up a DYNDNS account and have
>a domain (or simply your dynamic IP) pointing to your home machine so
>that localhost simply wouldn't be an issue.


I already have a domain pointed to this machine. If I change
httpd.conf between the folders I mentioned before, I see the change
immediately.

>Or install linux :) :) :)


I play with Ubuntu and DLS, they are great, but I gotta have
Dreamweaver and TopStyle. OTOH, I sure would like Asterisk PBX, but
don't think I could get it working in less than a couple weeks.

>I'm completely stumped, even after googling for
>"base href"+windows+localhost
>
>none of the examples within those results actually modifies the base root
>:(


Oh well, I sure appreciate all your efforts. Thanks, Marc.
Marc Bissonnette

2007-02-25, 6:16 pm

TexasLover <tex@slover> altered the spacetime fabric by disgorging
news:mck3u291gutu2acjck3tg6buqe0eciriad@4ax.com:

> On Sun, 25 Feb 2007 10:19:51 -0600, Marc Bissonnette
> <dragnet\_@_/internalysis.com> wrote:
>
>
> <snip>
>
>
> That's right, on a Windows box, root means the root of the drive.
>
>
> I already have a domain pointed to this machine. If I change
> httpd.conf between the folders I mentioned before, I see the change
> immediately.


So when you do that, does the <BASE HREF> work ? (I.e. without using
localhost as a value ) ?

>
> I play with Ubuntu and DLS, they are great, but I gotta have
> Dreamweaver and TopStyle. OTOH, I sure would like Asterisk PBX, but
> don't think I could get it working in less than a couple weeks.
>
>
> Oh well, I sure appreciate all your efforts. Thanks, Marc.


I really wish we could have solved it, 'cuz now it's going to bug me :)

I use UltraEdit as my text/html/perl editor, which has built-in save-as-
to-FTP, which makes doing all my testing on live servers much easier, so
I have to admit, I don't do a whole lot of local testing :(

Perhaps some other kind soul from this group would mind taking a stab at
it ?


--
Marc Bissonnette
Looking for a new ISP? http://www.canadianisp.com
Largest ISP comparison site across Canada.
TexasLover

2007-02-25, 10:19 pm

On Sun, 25 Feb 2007 15:45:32 -0600, Marc Bissonnette
<dragnet\_@_/internalysis.com> wrote:

>So when you do that, does the <BASE HREF> work ? (I.e. without using
>localhost as a value ) ?


No sir, that changes nothing.

>I really wish we could have solved it, 'cuz now it's going to bug me :)
>
>I use UltraEdit as my text/html/perl editor, which has built-in save-as-
>to-FTP, which makes doing all my testing on live servers much easier, so
>I have to admit, I don't do a whole lot of local testing :(
>
>Perhaps some other kind soul from this group would mind taking a stab at
>it ?


Doesn't UE rock? I couldn't live without it. I love my custom toolbar
with Save To FTP, Open From FTP, Sort, WordCount, Save All, Close All.
I've used search and replace across many hundreds of files. Lord, what
a great program.

Yeah, it'll bug me too. The answer will probably come to one of us
next week when we're doing something totally unrelated.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews