【问题标题】:Error in .htaccess File with Auto prepend + ErrorDocument + options带有自动前置 + ErrorDocument + 选项的 .htaccess 文件中的错误
【发布时间】:2019-05-06 20:04:43
【问题描述】:

我有这个.htaccess

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

但它给我发送了这个错误:

警告:未知:无法打开流:中没有这样的文件或目录 第0行未知

致命错误:未知:打开失败需要'./server/conferror.php' (include_path='C:\xampp\php\PEAR') 在第 0 行的未知

如果我删除 ErrorDocument 行,它工作得很好。 如果我设置ErrorDocument,并删除Options 行它工作正常但不阻止目录导航...

此文件是 php 错误的处理程序,需要通过 .htaccess php_value auto_prepend_file "./server/conferror.php" 预先添加

如何从.htaccess 阻止导航目录并同时输出到文件ErrorDocument 并保留前置文件。

【问题讨论】:

    标签: php .htaccess errordocument


    【解决方案1】:

    喜欢这个代码:

    # 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-10
      • 1970-01-01
      • 2016-02-16
      • 2013-01-04
      • 2023-04-03
      • 2011-01-09
      • 2016-10-12
      相关资源
      最近更新 更多