Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have access to an Ubuntu Machine with apache installed, which I connect to Using PuTTy.

For some reason my .htaccess file is not working, this is all it contains:

ErrorDocument 404 /handler.php

Instead of going to the handler.php page it prints out the general Not Found apache page.

I've searched Google and all I can find is information saying make sure in your apache config AccessFileName is set to .htaccess and AllowOverride is set to All.

I made the'e changes to my config file (/etc/apache2/apache2.conf) and it now contains this:

AccessFileName .htaccess

<Directory />
    AllowOverride All
    #AllowOverride None
</Directory>

I restarted apache (sudo /etc/init.d/apache2 restart), but I am still getting the exact same problem.

Sorry, I'm rather unfamiliar with Linux and Apache Config.

share|improve this question

migrated from stackoverflow.com May 23 '11 at 21:20

This question came from our site for professional and enthusiast programmers.

3  
does handler.php exist? Are you sure? –  gd1 May 23 '11 at 13:13
    
Which browser have you tested with? –  kapa May 23 '11 at 13:16
    
Definitely yes, and it's in the same directory as the .htaccess file –  Anonymous May 23 '11 at 13:18
    
Make sure the permissions on the .htaccess are accessible to the Apache user. Have you tried using handler.html? –  Abe Petrillo May 23 '11 at 13:18
2  
grep -R AllowOverride /etc/apache2 : try to see if any active configuration file (in conf.d or sites-enabled) is not putting some restrictions on a parent directory of your webroot (for / it's ok, but if someone can put a restriction on /var/www/mysite). You can check the .htaccess is read by setting deny from all inside (you should get access denied) –  regilero May 23 '11 at 15:15
show 13 more comments

2 Answers

up vote 2 down vote accepted

grep -R AllowOverride /etc/apache2 : try to see if any active configuration file (in conf.d or sites-enabled) is not putting some restrictions on a parent directory of your webroot (for / it's ok, but if someone can put a restriction on /var/www/mysite). You can check the .htaccess is read by setting deny from all inside (you should get access denied)

share|improve this answer
    
sorry about the late accept, just found this again! –  user491704 Dec 18 '11 at 20:57
add comment

Apache is not able to locate your handler.php file.

This file should reside in the DocumentRoot folder itself, of the VirtualHost (website).

Definitely yes, and it's in the same directory as the .htaccess file

This could be your problem. The path in that Directive is always relative to the DocumentRoot folder, not to the location of the .htaccess file.

Check URL http://www.example.com/handler.php as this is the URL you are telling Apache to redirect to.

http://httpd.apache.org/docs/2.2/mod/core.html#errordocument

share|improve this answer
    
This doesn't seem to me, because Apache would output the error page which tells "Error 404, additionaly an error 404 was encountered while trying to load the error page" or something like this. And he already checked for handler existence, you are some hours in the past. Hence -1 –  gd1 May 23 '11 at 15:07
    
Place this file in the DocumentRoot folder or modify to... ErrorDocument 404 /url-path/to/htaccess/file/folder/handler.php –  rightstuff May 23 '11 at 15:09
    
rightstuff most likely the .htaccess doesn't even get parsed, because otherwise apache, if it couldn't find the error handler, would have shown the other (modified) error page. –  gd1 May 23 '11 at 15:39
    
gd1 I understand what you are saying, but trusting that the user is making a distinction between the standard 404 and server modified 404 error message is unwise. –  rightstuff May 23 '11 at 16:08
    
The OP said the offending page is www.friendtrend.net/nopage This is a standard error hence the .htaccess is not parsed. –  gd1 May 23 '11 at 22:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.