【问题标题】:PHP Page Not Found error even though page exists即使页面存在,PHP Page Not Found 错误
【发布时间】:2019-12-25 06:17:42
【问题描述】:

当我调用 http://localhost/myapp 时,这将显示登录屏幕 (index.php),在接受并验证凭据后,会引发 404 Page Not found 错误。当我调试时,它进入“if”语句但无法加载页面。 dashboard.php 在 vi​​ews 文件夹下可用。

index.php

    //validation section

    if($usr2)
    {
            header('location: http://localhost/myapp/application/views/dashboard');
            //redirect("http://$_SERVER[HTTP_HOST]/myapp/application/views/dashboard");
    }

.htaccess(在 htdocs 文件夹中)

    RewriteEngine on
    RewriteBase /myapp/
    RewriteRule ^(.*)$ - 
    #RewriteCond $1 !^(index\.php) 
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?$1
    # browser requests PHP
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
    RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]
    # check to see if the request is for a PHP file:
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^/?(.*)$ /$1.php [L]

【问题讨论】:

  • htacess 文件必须在根目录下。你的index.php,
  • 我已将 .htaccess 放在根目录中(并重新启动了 Apache),但仍然出现相同的错误
  • 用户登录您的站点后。您重定向到dashboard.php 但服务器找不到页面?我说的对吗?
  • @ttrasn:你是对的,但是 php 页面存在。服务器响应页面未找到。
  • 你的框架是什么?我对你的框架处理程序很感兴趣

标签: php apache .htaccess http-status-code-404


【解决方案1】:

回答有点晚了,但要大写“位置”并将扩展名添加到您的路径中:

header('Location: http://localhost/myapp/application/views/dashboard.php');

【讨论】:

  • HTTP 标头不区分大小写。 Start-Case 仅用于漂亮的印刷品,易于眼睛。
猜你喜欢
  • 1970-01-01
  • 2020-05-25
  • 2015-10-16
  • 2014-07-23
  • 2022-06-15
  • 2020-12-05
  • 2012-09-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多