Forum Moderators: phranque

Message Too Old, No Replies

.htaccess in root directory

I can get .htaccess to work in specific subdirectories, but not the root

         

run4flat

8:16 pm on May 13, 2008 (gmt 0)

10+ Year Member



Greetings all -

I know, the solution to ensuring that .htaccess works is to not have ``AllowOverride none'' applied to my scope of interest. Unfortunately, it doesn't seem to be that simple.

FYI, I'm running apache2 on an Ubuntu 8.4 box.

The applicable portions of my apache2.conf file are
------------------------------------------------------

...
AccessFileName .htaccess
...
##################
# My modifications

# add the group_only directory as password protected
<Directory "/var/www/group_only">
AllowOverride AuthConfig
# The Options below is an example. Use what you deem is necessary.
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
</Directory>

# keep my own files separate from the group's pages
<Directory "/var/www/personal">
AllowOverride AuthConfig
# The Options below is an example. Use what you deem is necessary.
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
</Directory>

<Directory "/var/www">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
</Directory>

<Directory "/var/www/library">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
</Directory>

------------------------------------------------------
The first two Directory directives restrict a couple of directories and are cut-and-paste jobs. The last two Directory directives tell apache to use the .htaccess file in the specified directory. The ``AllowOverride All'' gives .htaccess its full range of options.

Now, at the very bottom of apache's documentation for .htaccess, which is located at [httpd.apache.org...] , they say that you should "Make sure that you don't have a AllowOverride None in effect for the file scope in question. A good test for this is to put garbage in your .htaccess file and reload. If a server error is not generated, then you almost certainly have AllowOverride None in effect."

Here's the kicker. When I put a giberish .htaccess file in /var/www/library and navigate to localhost/library/, I get a server error. When I put the same file in /var/www/ and navigate to localhost/, I have no errors at all and it loads the index page without trouble. I've even checked that the file permissions are the same.

So, why would .htaccess have an effect in a subdirectory but not in a root directory?

David

jdMorgan

2:46 pm on May 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two questions:

1) What is DocumentRoot defined as?
2) Are you using MultiViews (content negotiation)? If not, turn it off.

Jim

run4flat

6:33 pm on May 15, 2008 (gmt 0)

10+ Year Member



Hey Jim -

1) DocumentRoot is /var/www
2) I am not using content negotiation, so I will turn it off.

I'm not sure if you did this intentionally, but you're sending me off to find DocumentRoot led me to find a <Directory> directive in one of the many apache server configuration files which indicated "AllowOverride None" for /var/www. For future reference for anybody who is having the same trouble on Ubuntu 8.4, apache2 or similar, the document within /etc/apache2/sites-enabled (there was only one on mine) had the directives for the DocumentRoot folder. However, anybody who is planning on making changes to these settings should probably read or have read the .htaccess writeup in apache's documentation (linked in my original post).

Thanks Jim, I'll hammer away at it from here. If I run into irresolvable trouble later I'll check back.

David