kirby
kirby

Reputation: 4041

.htaccess not working as expected

My .htaccess file isn't working. I have checked that it is in the root directory. I also verified that it's code is correct. When I type random letters/numbers into the .htaccess I do not get a 500 error. When i open my apache error log, it gives me this error:

[Mon Jan 16 20:28:37 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Mon Jan 16 20:28:41 2012] [notice] Digest: generating secret for digest authentication ...
[Mon Jan 16 20:28:41 2012] [notice] Digest: done
[Mon Jan 16 20:28:44 2012] [notice] Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

I don't know what to do.

http.conf:

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

Upvotes: 0

Views: 1875

Answers (1)

Arjan
Arjan

Reputation: 9884

There are a few possible reasons your random, invalid, .htaccess file would not cause an http error 500 (internal server error):

  • Incorrect file name. It must be .htaccess. The first character is a dot. The last character is a lower case 's'. Hidden extensions might cause problems because an incorrect file name could appear to be correct.
  • The file location is incorrect. Try placing the file next to your html files, in the same folder. If that works, you could move the file up one folder and try again.
  • The Apache configuration does not allow for .htaccess files. If the configuration option AllowOverride is set to None in the apache configuration files (for the specified domain), then Apache will not look for any .htaccess files.

Also note that .htaccess files are ignored when you access your files using the file:// protocol.

Update

The paths used in .htaccess refer to file system paths, not url paths. Based on the .htaccess content you posted, nobody has access to any files on your webserver. I would suggest something like:

<Directory />
    # Security first, deny everything that's not explicitly allowed.
    AllowOverride None
    Order deny, allow
    Deny from all
</Directory>

<Directory /path/to/webroot>
    # This is the part that should be accessible
    Options FollowSymLinks
    AllowOverride All
    Order allow, deny
    Allow from all
</Directory>

Your .htaccess file should be in /path/to/webroot Note that you should change /path/to/webroot to something sensible that matches your file system.

Upvotes: 3

Related Questions