简体   繁体   English

找不到PHP MVC网址404

[英]PHP MVC url Not Found 404

I am getting a URL not found error in my MVC Php application . 我的MVC Php应用程序中出现URL not found错误 The .htacess file seems fine and apache is configured well because the other application runs well. .htacess文件似乎很好,并且apache配置正确,因为其他应用程序运行良好。 Am hosting my mysql db on amazon. 我在亚马逊上托管我的mysql数据库。

here is my code snippet. 这是我的代码段。

LoginForm.php 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 .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 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 我花了将近13个小时试图弄清楚我做错了什么,但是如果知道的话会很高兴

请检查mod_rewrite是否正常工作,您可以从这里获取帮助: https : //docs.bolt.cm/3.0/howto/making-sure-htaccess-works

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM