You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Bill Gradwohl <bi...@ycc.com> on 2010/12/16 21:06:00 UTC

[users@httpd] DocumentRoot isn't the root for an absolute reference.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Given the following in the httpd.conf file on a development machine that
is NOT the real web server for the domains:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin xxx@ycc.com
    DocumentRoot /var/www/html
    ServerName _default_
    <Directory /var/www/html>
       AllowOverride Options
       XBitHack On
       Options Indexes MultiViews +Includes
       Order allow,deny
       allow from all
    </Directory>
</VirtualHost>

# Below are all the real virtual host definitions.
<VirtualHost *:80>
    ServerAdmin xxx@ycc.com
    DocumentRoot /var/www/html/roatanbakery.com
    ServerName roatanbakery.com
    ServerAlias www.roatanbakery.com
    ErrorLog /var/log/httpd/roatanbakery.com-error_log
    CustomLog /var/log/httpd/roatanbakery.com-access_log common
    <Directory /var/www/html/roatanbakery.com>
       AllowOverride Options
       XBitHack On
       Options Indexes MultiViews +Includes
       Order allow,deny
       allow from all
    </Directory>
</VirtualHost>
.....
.....

When I use Firefox via http://localhost/roatanbakery.com/ , the page
comes up broken with no css and no ssi's working.

The offending html for the css is:
<link href="/common/style.css" rel="stylesheet" type="text/css" />

Similarly, for the ssi:
<!--#include virtual="/common/w3c.inc.html" -->

If I remove the leading / in each reference, everything works.

Because the ssi fails, I know its a server issue.

Here is the actual structure (extraneous items removed):
root@box1 roatanbakery.com# pwd
/var/www/html/roatanbakery.com
root@box1 roatanbakery.com# tree
.
├── bakery
│   └── images
......
├── common
│   └── images
......
│   ├── style.css
│   └── w3c.inc.html
└── toolbars
├── index.html

The error log shows:
File does not exist: /var/www/html/common

It successfully finds the index.html at the document root. Why does it
not find the 2 files when a leading / is used, as that also represents
the root. It apparently used the default DocumentRoot to look for these
files, and not the one specifically specified for the virtual.

How does one successfully write an ABSOLUTE reference in the HTML
against the DocumentRoot that ALWAYS works? Or, is the error in the
httpd.conf file? I don't like using relative references
(common/style.css or ../../common/style.css for example) because it
changes depending on the current level.

I need this to work, as is, when I transfer the entire structure from
the development server to the real web server in Texas.

- -- 
Bill Gradwohl
Roatan, Honduras
504 9 899 2652
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk0KcSgACgkQ7Orvev+eC8rNXwCaAkOIrW+pzvpXcTdN758F0RGZ
bv4An3Nuk6KfylLvPCpktUug9M0Jl/gL
=3kcy
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DocumentRoot isn't the root for an absolute reference.

Posted by Eric Covener <co...@gmail.com>.
> When I use Firefox via http://localhost/roatanbakery.com/ , the page
> comes up broken with no css and no ssi's working.

This is working as designed, you're hitting the default virtualhost
because your client is NOT asking for the hostname "rotanbakery.com".

Mock this up in your hosts file and use the real URLS, which will
result int he real Host headers and the desired name-based vhost being
selected.

The only reason you get the "right" result for the index is because
you've tacked on the name of the subdirectory.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] DocumentRoot isn't the root for an absolute reference.

Posted by Afsar Mohiuddin <af...@hotmail.com>.
Frank is right. Don't put under the same folder. Create separate path for each and correct all DocumentRoot reference to your base.
 
> Date: Thu, 16 Dec 2010 14:34:20 -0600
> From: bill@ycc.com
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] DocumentRoot isn't the root for an absolute reference.
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 12/16/2010 02:08 PM, Frank Gingras wrote:
> > 
> > Best not to use overlapping DocumentRoot paths in different vhosts.
> > 
> > Frank.
> 
> Please elaborate. I don't understand why this should be so.
> 
> If the base for vhosts is /var/www/html then having them all under that
> base makes sense - doesn't it?
> 
> 
> - -- 
> Bill Gradwohl
> Roatan, Honduras
> 504 9 899 2652
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk0Kd8sACgkQ7Orvev+eC8rLlQCeOxDVZ1BSJgwtl7NPawax4VkG
> haQAniFdG5YLTMYH4B+BcIsJwe4k+8zz
> =cDHx
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
 		 	   		  

Re: [users@httpd] DocumentRoot isn't the root for an absolute reference.

Posted by Bill Gradwohl <bi...@ycc.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/16/2010 02:08 PM, Frank Gingras wrote:
> 
> Best not to use overlapping DocumentRoot paths in different vhosts.
> 
> Frank.

Please elaborate. I don't understand why this should be so.

If the base for vhosts is /var/www/html then having them all under that
base makes sense - doesn't it?


- -- 
Bill Gradwohl
Roatan, Honduras
504 9 899 2652

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk0Kd8sACgkQ7Orvev+eC8rLlQCeOxDVZ1BSJgwtl7NPawax4VkG
haQAniFdG5YLTMYH4B+BcIsJwe4k+8zz
=cDHx
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DocumentRoot isn't the root for an absolute reference.

Posted by Frank Gingras <fr...@gmail.com>.

On 12/16/2010 03:06 PM, Bill Gradwohl wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Given the following in the httpd.conf file on a development machine that
> is NOT the real web server for the domains:
>
> NameVirtualHost *:80
>
> <VirtualHost *:80>
>      ServerAdmin xxx@ycc.com
>      DocumentRoot /var/www/html
>      ServerName _default_
>      <Directory /var/www/html>
>         AllowOverride Options
>         XBitHack On
>         Options Indexes MultiViews +Includes
>         Order allow,deny
>         allow from all
>      </Directory>
> </VirtualHost>
>
> # Below are all the real virtual host definitions.
> <VirtualHost *:80>
>      ServerAdmin xxx@ycc.com
>      DocumentRoot /var/www/html/roatanbakery.com
>      ServerName roatanbakery.com
>      ServerAlias www.roatanbakery.com
>      ErrorLog /var/log/httpd/roatanbakery.com-error_log
>      CustomLog /var/log/httpd/roatanbakery.com-access_log common
>      <Directory /var/www/html/roatanbakery.com>
>         AllowOverride Options
>         XBitHack On
>         Options Indexes MultiViews +Includes
>         Order allow,deny
>         allow from all
>      </Directory>
> </VirtualHost>
> .....
> .....
>
> When I use Firefox via http://localhost/roatanbakery.com/ , the page
> comes up broken with no css and no ssi's working.
>
> The offending html for the css is:
> <link href="/common/style.css" rel="stylesheet" type="text/css" />
>
> Similarly, for the ssi:
> <!--#include virtual="/common/w3c.inc.html" -->
>
> If I remove the leading / in each reference, everything works.
>
> Because the ssi fails, I know its a server issue.
>
> Here is the actual structure (extraneous items removed):
> root@box1 roatanbakery.com# pwd
> /var/www/html/roatanbakery.com
> root@box1 roatanbakery.com# tree
> .
> ├── bakery
> │   └── images
> ......
> ├── common
> │   └── images
> ......
> │   ├── style.css
> │   └── w3c.inc.html
> └── toolbars
> ├── index.html
>
> The error log shows:
> File does not exist: /var/www/html/common
>
> It successfully finds the index.html at the document root. Why does it
> not find the 2 files when a leading / is used, as that also represents
> the root. It apparently used the default DocumentRoot to look for these
> files, and not the one specifically specified for the virtual.
>
> How does one successfully write an ABSOLUTE reference in the HTML
> against the DocumentRoot that ALWAYS works? Or, is the error in the
> httpd.conf file? I don't like using relative references
> (common/style.css or ../../common/style.css for example) because it
> changes depending on the current level.
>
> I need this to work, as is, when I transfer the entire structure from
> the development server to the real web server in Texas.
>
> - --
> Bill Gradwohl
> Roatan, Honduras
> 504 9 899 2652
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk0KcSgACgkQ7Orvev+eC8rNXwCaAkOIrW+pzvpXcTdN758F0RGZ
> bv4An3Nuk6KfylLvPCpktUug9M0Jl/gL
> =3kcy
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See<URL:http://httpd.apache.org/userslist.html>  for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>     "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>

Bill,

Best not to use overlapping DocumentRoot paths in different vhosts.

Frank.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DocumentRoot isn't the root for an absolute reference.

Posted by Bill Gradwohl <bi...@ycc.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/16/2010 02:52 PM, Joost de Heer wrote:
> localhost isn't in the ServerName/-Alias, so the first (default) host is
> used, and the documentroot for that host is /var/www/html. A reference
> to /common/style.css will result in a request for the file
> /var/www/html/common/style.css.


Thank You Frank, Eric, Afsar, & Joost. I"m beginning to understand why
and how this is happening.

I can't reasonably create a lie on my development box (i.e. hosts fix)
because I need to hit my real domain server in Texas for my email, and I
also ssh into it to maintain it. I can't fudge the DNS.

I see now that the problem on my dev box is that I'm trying to get the
web site to function from a directory/file perspective, and my real box
is functioning from a DNS hostname perspective, so to speak.

I've had this problem for quite some time causing me to "fix" the html
when I move it to the real box, and it finally bothered me enough to try
to figure out what's going on.

So - How do I set up the dev box to 100% mimic the real box while I'm
testing so I don't have to hand massage the code when I move it? I can't
be the first guy to run into this, so is there a consensus on how to
approach the problem?

Having different httpd.conf files (real vs dev) is fine and expected.


- -- 
Bill Gradwohl
Roatan, Honduras
504 9 899 2652

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk0Kjn4ACgkQ7Orvev+eC8rQcgCeLZFXJFmTHw8UkHtj6yCD7KZl
b4oAn2uv3Wn4ogT3RomNlVYQmXzPBxKx
=jQb+
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DocumentRoot isn't the root for an absolute reference.

Posted by Joost de Heer <jo...@sanguis.xs4all.nl>.
> # Below are all the real virtual host definitions.
> <VirtualHost *:80>
>      ServerAdmin xxx@ycc.com
>      DocumentRoot /var/www/html/roatanbakery.com
>      ServerName roatanbakery.com
>      ServerAlias www.roatanbakery.com
> </VirtualHost>

> When I use Firefox via http://localhost/roatanbakery.com/ , the page
> comes up broken with no css and no ssi's working.

localhost isn't in the ServerName/-Alias, so the first (default) host is used, 
and the documentroot for that host is /var/www/html. A reference to 
/common/style.css will result in a request for the file 
/var/www/html/common/style.css.

Joost

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org