简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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