logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: issues with directory index/virtual host
Author
fubowl



Joined: 27 Dec 2009
Posts: 1

PostPosted: Sun 27 Dec '09 16:41    Post subject: issues with directory index/virtual host Reply with quote

Hi all,

I'm having an issue where I've created a virtual host successfully but when I access the content of said virtual host (http://fhr.local), the directory index is appended to my file so it shows up above my content. I've turning off directory indexing in an attempt to bypass the problem and have done so by editing the httpd.conf file as per the following code.

This code only works if I keep the "Options -Indexes" under ServerName local. If this is removed, the second "Options -Indexes" under ServerName fhr.local is ineffective.

Any solutions for why this would be occurring would be greatly appreciated.

Apache 2.2
EasyPHP 2

httpd.conf:
Code:
NameVirtualHost localhost:80

 <VirtualHost localhost:80>
    ServerAdmin b@g.com
    ServerName local
    DocumentRoot "C:/Program Files/EasyPHP5.3.0/www"

<Directory "C:/Program Files/EasyPHP5.3.0/www">
AllowOverride All
Options -Indexes
</Directory>

 </VirtualHost>

 <VirtualHost localhost:80>
    ServerAdmin b@g.com
    ServerName fhr.local
    DocumentRoot "C:/Program Files/EasyPHP5.3.0/www/fhr"

<Directory "C:/Program Files/EasyPHP5.3.0/www/fhr">
Options -Indexes
AllowOverride All
</Directory>

 </VirtualHost>
Back to top
bovcan



Joined: 15 Dec 2009
Posts: 19
Location: Slovenia

PostPosted: Sun 27 Dec '09 19:17    Post subject: Reply with quote

Why do you have 2 times <VirtualHost localhost:80> for differnet folders?
Try to add for localhost
<VirtualHost localhost:80>
DocumentRoot "C:/Program Files/EasyPHP5.3.0/www"

and for
DocumentRoot "C:/Program Files/EasyPHP5.3.0/www/fhr"
you will need to add something else not localhost again
EXP: <VirtualHost www.yourdomain.com:80>
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Mon 28 Dec '09 6:13    Post subject: Reply with quote

not so bovcan,

<VirtualHost IP:80>. You can have as many vhost bound to any one IP you want, and localhost is simply the IP 127.0.0.1, the ServerName needs to be different for each. <VirtualHost *:80> will listen on ALL IP addresses. It has to do with name-based vs. ip-based virtualhosts and you can have both in one config as well.

I am unfamiliar with EasyPHP, but something that has my curiousity going is what the file name is in each of the folders your trying to view. If it were readme.html the same things you are describing could happen per
http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html#readmename
provided you have not changed DirectoryIndex and are calling with just
http://local or http://local.jhp

My sneaky suspicion is you are not actually getting one of those two vhosts due to the ol' "main host goes away" section of http://httpd.apache.org/docs/2.2/vhosts/name-based.html

This is the most common mistake cause it is almost always overlooked and I have written about it in this forum more times than I care to count. Your first vhost should be a minimal duplicate of the main host in httpd.conf, until then it is up in the air on how Apache will act, it seems to be different for different people or they just explain the symptoms differently.

Why the directories do not act properly: this could be due to the fact they are per virtual host and not global but most likely my sneaky suspicion as stated above. When you are going to http://local.jhp you are really ending up at http://local or worse, whatever the main host is in httpd.conf

Code:


<VirtualHost *:80>
    <Directory "c:/some/path/to/something">
        Everything in here will only be used by this vhost only
    </Directory>
</VirtualHost>

<Directory "c:/some/path/to/something/else">
    Everything in here will only be used by any host since it is
    not inside a <VirtualHost> container and is therefore global.
</Directory>


How to test theory;

In the directory of the main host in httpd.conf create a file called index.html and it simply have the words "Main Host"

For vhost "local" do the same but in that index.html file just put in "Local"
For vhost "local.jhp" do the same but in that index.html file just put in "Local JHP"

now call http://local.jhp
which file do you actually see?
Back to top


Reply to topic   Topic: issues with directory index/virtual host View previous topic :: View next topic
Post new topic   Forum Index -> Apache