【发布时间】:2019-12-25 06:17:42
【问题描述】:
当我调用 http://localhost/myapp 时,这将显示登录屏幕 (index.php),在接受并验证凭据后,会引发 404 Page Not found 错误。当我调试时,它进入“if”语句但无法加载页面。 dashboard.php 在 views 文件夹下可用。
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