LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Apache Default Index (https://www.linuxquestions.org/questions/linux-newbie-8/apache-default-index-304858/)

Cool_Hand_Luke 03-22-2005 05:43 PM

Apache Default Index
 
Ok, I have apache configured to default to index.html in directories other then root. Is there away to configuring it so I don't need the slash?


Just curious as I hate it when a server error pops up if someone forgets to enter the slash.

Cheers,

Cool Hand...

calcon 03-22-2005 05:46 PM

I don't thinks this is a Linux issue, it is an Apache issue.

Anywho, I would try using Mod Rewrite (http://httpd.apache.org/docs/mod/mod_rewrite.html). I've never used it, so I can't be of help there, but take a look at the link I gave you.

calcon

DaHammer 03-23-2005 01:08 AM

Drop the trailing slash off your DocumentRoot and/or Directory directives.

ie use

DocumentRoot /var/www

<Directory /var/www/somefolder>
...........
</Directory>

Cool_Hand_Luke 03-23-2005 06:25 AM

Bamm baby Thanks! I'll test that out tonight.


Cheers,

Cool Hand...

Cool_Hand_Luke 03-24-2005 09:00 AM

Quote:

Originally posted by DaHammer
Drop the trailing slash off your DocumentRoot and/or Directory directives.

ie use

DocumentRoot /var/www

<Directory /var/www/somefolder>
...........
</Directory>

So I tried the above,

DocumentRoot /var/www/html

<Directory /var/www/html/camscamps>

nothing is here now..... should there be?
</Directory>


Doesn't seem to do anything. I restarted the server and I still need to type..

http://www.example.com/camscamps/

I would really like to get rid of that slash at the end....

Cheers,

Luke

stickman 03-24-2005 12:43 PM

Are you loading mod_dir?

From the Apache website: 'Provides for "trailing slash" redirects and serving directory index files'

DaHammer 03-24-2005 11:20 PM

Quote:

Originally posted by Cool_Hand_Luke
So I tried the above,

DocumentRoot /var/www/html

<Directory /var/www/html/camscamps>

nothing is here now..... should there be?
</Directory>

Yes, there should be something there else there is no need for the "Directory" directive. I posted that directive only as an example if you're using it. The "Directory" directive is used to set settings for specific directories. You'd have one for the root of your site and then you'd use others to add or change things on a directory by directory basis, if you need to. For instance, I disallow all access to the root of my site by default:
Code:

<Directory />
    Options None
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

So then I'd use it to allow access to one of the virtualhosts:
Code:

<Directory "/www/www.somesite.org">
    Order allow,deny
    Allow from all
</Directory>

Now anyone can access anything under that website. But then I have another directory where I want to list files vs load an index.html, so I add a few mod_autoindex options for that directory that I want to use:
Code:

<Directory "/www/www.somesite.org/files">
    IndexOptions FancyIndexing
    ReadmeName README.TXT
    Options Indexes FollowSymlinks
</Directory>

Anyway, I simply meant to not add the "/" at the end for those directives. That's all. The manual states the following:
Quote:

There appears to be a bug in mod_dir which causes problems when the DocumentRoot has a trailing slash (i.e., "DocumentRoot /usr/web/") so please avoid that.
But yes, as stickman stated, you need to make sure that mod_dir is loaded for the redirects to work correctly. It usually is in most default httpd.conf files. Also, you should probably run "/path/to/httpd -t" to test your configuration after making changes, as well.

Cool_Hand_Luke 03-25-2005 11:16 AM

Thank you :) It worked.

Cheers,

Cool Hand...


All times are GMT -5. The time now is 08:12 PM.