普通网友 2016-09-27 09:22
浏览 32

PHP MVC url Not Found 404

I am getting a URL not found error in my MVC Php application. The .htacess file seems fine and apache is configured well because the other application runs well. Am hosting my mysql db on amazon.

here is my code snippet.

LoginForm.php

/** * */

 class LoginForm extends Controller {

public $model;

public function index() {

    //check if they are already logged in

    if (!isset($_SESSION['email'])) {


        require 'application/views/login/index.php';

    } else {
        //redirect to admin data
        header("Location:" . URL . "home");
    }
}

public function login() {
    // get the post

    $this->model = $this->loadModel('login');
    if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['country'])) {
        //  echo "priv_".$_POST["country"];
        $validate = $this->model->validate($_POST['email'], MD5($_POST['password']), $_POST["country"], 1);

        if ($validate != 0) {

            // get  all the data
            $data = $this->model->getByID($_POST['email']);

            /*
              echo "<pre>";
              var_dump($data);
              echo "</pre>";
              exit();

             */
            // set the session
            session_start();
            $_SESSION['email'] = $_POST['email'];


            /*
             * Privilege Sesssion settings Start
             * 
             */


            $_SESSION["pnya"] = $data[0]['pnya'];

            /*
             * Privilege Session End
             */
            header("Location:" . URL . "home");
        } else {
            header("Location:" . URL . "LoginForm");
        }
    } else {
        // @todo reload login page page
        header("Location:" . URL . "LoginForm");
        // @todo wth appropriate errors
    }
    // use php to check if its an email
    // if not set the errors
    // @todo use model to get dta a from staff and validate
    // @todo if it all succeeds then rdirect
}

public function logout() {
    // destroy the session
    session_start();
    session_destroy();

    // redirect to login page
    header("Location:" . URL . "LoginForm");
}

}

?>

.htacess

   Options -MultiViews
   RewriteEngine On
   Options -Indexes
   RewriteBase /MIS/ysw/

   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

config.php

  error_reporting(E_ALL);
  ini_set("display_errors", 1);

  define('URL', 'http://42.11.223.45/MIS/ysw/');


  define('DB_TYPE', 'mysql');
  define('DB_HOST', 'XXX');
  define('DB_NAME', 'amazon');
  define('DB_USER', 'xxxx');
  define('DB_PASS', 'ddddd');

I have spent close to 13hrs trying to figure out what I have not done right, but will be glad if informed

  • 写回答

1条回答 默认 最新

  • doufu2496 2016-09-27 09:29
    关注

    Please check if mod_rewrite is working, you can take help from here: https://docs.bolt.cm/3.0/howto/making-sure-htaccess-works

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建