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

I have an Apache 2 server and it have several vhosts with similar definition:

<VirtualHost *:80>
    DocumentRoot /var/www/html/host1/
    ServerName host1.loc
    <Directory /var/www/html/host1>
        AllowOverride FileInfo Options AuthConfig
    </Directory>
    ErrorDocument 404 /index.php?error=404
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot /var/www/html/host2/
    ServerName host2.loc
    <Directory /var/www/html/host2>
        AllowOverride FileInfo Options AuthConfig
    </Directory>
    ErrorDocument 404 /index.php?error=404
</VirtualHost>
...
<VirtualHost *:80>
    DocumentRoot /var/www/html/hostN/
    ServerName hostN.loc
    <Directory /var/www/html/hostN>
        AllowOverride FileInfo Options AuthConfig
    </Directory>
    ErrorDocument 404 /index.php?error=404
</VirtualHost>

I would like to customize page 404.

The problem is that when I try to test 404 page in any of the hosts, I can see the page from the very last vhost. What could be wrong with my config?

share|improve this question
    
What happens when you change it into a static message like ErrorDocument 404 "File not found on vhost hostN"? Do you get the right messages? Try placing the ErrorDocument directive inside of the Directory directive. –  dtech Dec 13 '13 at 19:43
    
Could you update your post with at least two <virtualHost>...</virtualHost> directive you have ? –  krisFR Dec 13 '13 at 20:30
    
@dtech, it looks like there is no effect. It looks like this directive is completely ignored in every vhost except the very last one. –  Antonio Dec 13 '13 at 20:35
    
@user2196728, I added several more of them –  Antonio Dec 13 '13 at 20:38
1  
"what about .htaccess ?" was planed to be my next question :) glad it works –  krisFR Dec 13 '13 at 21:27

1 Answer 1

Use an html file instead of php one.

ErrorDocument 404 /custom_error_404.html
share|improve this answer
1  
I am quite sure a php file can be used for custom 404...or other –  krisFR Dec 13 '13 at 19:39

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.