php.htaccesserrordocument

Error in .htaccess File with Auto prepend + ErrorDocument + options


i have this .htaccess:

Options -Indexes
ErrorDocument 403 /server/403.php
php_value auto_prepend_file "./server/conferror.php"

but it send me this error:

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

Fatal error: Unknown: Failed opening required './server/conferror.php' (include_path='C:\xampp\php\PEAR') in Unknown on line 0

if i Remove ErrorDocument Line it work good. if i set ErrorDocument, and remove Options Line it Work Fine but not block Directory navigation...

this File is a handler for php error that need to be prepend via .htaccess php_value auto_prepend_file "./server/conferror.php"

How can i make work from .htaccess prevent navigation directory and ouput to file ErrorDocument at same time and Preserve the prepend file.


Solution

  • Soved with this code:

    # Control de Errores
    php_value auto_prepend_file "server/conferror.php"
    # Disable directory browsing 
    Options -Indexes
    # Hide the contents of directories
    IndexIgnore *
    # Hide files of type .png, .zip, .jpg, .gif and .doc from listing
    IndexIgnore *.png *.zip *.jpg *.gif *.doc *.pdf *.txt *.jpeg *.log
    # Allow access to php files
    <Files *.log>
        deny from all
    </Files>
    <Files *.php>
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
    </Files>
    <Files index.php>
        Order Allow,Deny
        Allow from all
    </Files>
    <Files signal.php>
        Order Allow,Deny
        Allow from all
    </Files>
    # Mal Request
    ErrorDocument 400 server/400.html
    # No Autorizado
    ErrorDocument 401 server/401.html
    # Acceso Prohibido
    ErrorDocument 403 server/403.html
    # No Encontrada
    ErrorDocument 404 server/404.html
    # Error interno del Servidor
    ErrorDocument 500 server/500.html