You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by ARTHUR GOLDBERG <ar...@cs.nyu.edu> on 2009/07/28 19:54:21 UTC

[users@httpd] Question on DirectoryIndex

Hi

(Hope this isn't a dupe. I just registered.)

Running
Server version: Apache/2.2.3
Server built:   Jul  6 2009 05:29:28

Our website's accessed at two domains, like site.org and x.site.edu.
It's largely driven by Perl programs loaded by mod_perl, but has some  
static content.
I want to configure it so that all requests for directory URLs map to  
index.html in DocumentRoot.

My impression from http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex 
  is that one way would be to have httpd.conf say
DirectoryIndex /index.html

and have that index.html in turn say
<meta http-equiv="Refresh" content="0; url=http://site.org">

but I understand that Refresh isn't recommended (http://en.wikipedia.org/wiki/Meta_refresh 
). Furthermore, a test shows that this works for URLs asking for  
directories in site.org but not x.site.edu.

It seemed that another alternative is to define
DirectoryIndex /cgi-bin/directory/

in httpd.conf where '/cgi-bin/directory/' is the root directory of  
requests served by Perl, but that produces an "Attempt to serve  
directory: /scriptroot/cgi-bin/" error that I didn't expect.

BR
Arthur

Also, is there a way to have a running Apache httpd output the  
directives it knows?

Re: [users@httpd] Question on DirectoryIndex

Posted by André Warnier <aw...@ice-sa.com>.
André Warnier wrote:
...
Addendum :
Note that if are really courageous, you should really have a look at 
this documentation page (something I should also do seriously some day) :
http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html

This stuff looks like it can do just about anything you'd want to do in 
terms of directory indexes, and even many things you'd never even think 
of doing.
And it's standard Apache.


---------------------------------------------------------------------
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] Question on DirectoryIndex

Posted by André Warnier <aw...@ice-sa.com>.
ARTHUR GOLDBERG wrote:
> Hi
> 
> (Hope this isn't a dupe. I just registered.)
> 
Nope, you're doing fine.

> Running
> Server version: Apache/2.2.3
> Server built:   Jul  6 2009 05:29:28
> 
Thanks, always helpful.

> Our website's accessed at two domains, like site.org and x.site.edu.
> It's largely driven by Perl programs loaded by mod_perl, but has some 
> static content.
> I want to configure it so that all requests for directory URLs map to 
> index.html in DocumentRoot.
> 
That's one I cannot answer.
...
But the next one I can :
> 
> It seemed that another alternative is to define
> DirectoryIndex /cgi-bin/directory/
> 
> in httpd.conf where '/cgi-bin/directory/' is the root directory of 
> requests served by Perl, but that produces an "Attempt to serve 
> directory: /scriptroot/cgi-bin/" error that I didn't expect.
> 
Right.
The correct form is
DirectoryIndex /cgi-bin/my_index_generating_script.pl

In other words :
- create a perl script which always returns the content of your 
DocumentRoot directory, as a nicely-formatted html page.
- then set this as being the DirectoryIndex for your top directory, like

DocumentRoot /var/www/site1
...
<Location />
  DirectoryIndex /cgi-bin/my_index_generating_script.pl
</Location>

and do this in each of your VirtualHost sections, and it should work as 
you wish.

That's one way, anyway.  There may be easier ones, but considering that 
you are already using mod_perl, that's probably the most powerful one to 
output exactly what you want.

> 
> Also, is there a way to have a running Apache httpd output the 
> directives it knows?

I don't think so.  But if you are trying to start an Apache whose config 
file contains directives it does /not/ know, it will sure tell you.. ;-)

Depending on what you are really trying to achieve though, always a good 
reference is
http://httpd.apache.org/docs/2.2/mod/directives.html
If you click on any directive, the first informational box will always 
tell you if this directive is part of "core" Apache (meaning that even 
the barest-bone Apache will recognise it), or of some add-on module.
If it is part of an add-on module, then unless that module is loaded in 
your configuration (LoadModule xxxxxx), using that directive will get 
you a nice message like :
"Invalid directive xxxxxxx or handled by a module not loaded in your 
configuration"
and Apache will not start.



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