【问题标题】:How correctly redirect to error page? php如何正确重定向到错误页面? php
【发布时间】:2016-07-22 11:02:18
【问题描述】:

如何重定向到我的错误页面?

我的目录结构:

.htaccess 文件内部:

ErrorDocument 404 /Index.php?controller=Main&action=error

我不知道如何正确判断,但它会将我重定向到 ../ 后一级..,在 xampp 中 ../ 将是索引文件...并显示:

我想将 404 错误重定向到索引。

我尝试在 .htaccess 文件中添加这一行:

 ErrorDocument 404 Index.php?controller=Main&action=error

但没有 / 闪烁其显示文本,如下所示:

【问题讨论】:

    标签: php .htaccess xampp


    【解决方案1】:

    输入绝对 URI,例如 ErrorDocument 404 /Index.php?controller=Main&action=error

    见https://httpd.apache.org/docs/2.4/mod/core.html#errordocument

    【讨论】:

    • 但是使用 ErrorDocument 404 /Index.php?controller=Main&action=error 这会将我重定向回一级,但我的索引文件位于根目录中,其中 .htaccess 文件。我可以使用这个:ErrorDocument 404 localhost:8080/flowers/…,但我认为没有网页链接会更好
    • 我没有发现问题,使用绝对路径:ErrorDocument 404 /flowers/Index.php?controller=Main&action=error
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-06
    • 1970-01-01
    • 2013-07-07
    • 2014-03-12
    • 2017-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多