0

edited for clarification, because all answers/comments where talking about other things then the topic until now

I verified that my apache.conf (Ubuntu) says, that it looks for .htaccess and that it allows .htaccess to override everything:

#...
AccessFileName .htaccess
#...
<Directory /var/www>
AllowOverride All
Options FollowSymlinks
</Directory>

Then I put the following .htaccess (with rights 755) into my /var/www:

order allow, deny
deny from all

Then I restarted my server as root to make sure the config is loaded again and no fileaccess rights can harm my experiment: sudo apache2ctl restart

The result is that he still opens the folder as if there would be no .htaccess. What could be wrong? What else can I check to make sure that it works properly?

edit: I also checked if writing garbage creates an error message and it doesn't!

3
  • If you provide better information, we can give a better answer. Include the result of namei -m /home/erikb/.htusers, and the permissions for both /var/www and your home html dir.
    – adaptr
    Dec 2, 2011 at 13:46
  • @adaptr everything is 744 or 755 with erikb/erikb or root/root. Because I started the Apache as root and verified that symlinks work appropriately, there should be no problem in this direction.
    – erikbstack
    Dec 2, 2011 at 14:16
  • Apache does not run as root.
    – adaptr
    Dec 2, 2011 at 16:58

1 Answer 1

3
<Directory />
AllowOverride All
</Directory>

You should not do this; this references the filesystem root.
Instead, only define permissive AllowOverrides from your documentroot on down.
(And, optionally, in your UserDirs)

the server looks for /var/www/ as his webdirectory and inside I linked to another folder in my home directory

To allow symlinking, FollowSymLinks must be set for the source directory (in your case, /var/www)

Instead of these insecure settings, use the following:

<Directory />
  AllowOverride None
  Order allow,deny
  Deny From All
</Directory>

<Directory /var/www>
  AllowOverride All
  Options FollowSymlinks
</Directory>

NOTE that for apache to actually read the symlinked files, they must be accessible; in most cases, this means the directories and files must be world-readable, and the directories world-executable.

3
  • Of course I will change the folder in <Directory> later on. I just want to make sure that I can do it at all. Also I verified that symlinking works. He starts php and html files from inside my symlinked folder and also shows me the +Indexes stuff.
    – erikbstack
    Dec 2, 2011 at 13:44
  • Seconded, you should put the AllowOverride on your DocumentRoot and not on your entire filesystem, that's bad practice.
    – Oldskool
    Dec 2, 2011 at 13:44
  • @Oldskool it is not at all about practise but about making it work. Allowing your system more then it should be allowed can't break anything. I am looking for what is broken now.
    – erikbstack
    Dec 2, 2011 at 14:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .