Object not found! after route redirection in Fuel php

The following is the directory structure of my fuelphp project

  • fuel
  • magazines
  • the public
  • Tmp

In the shared folder I have

  • assets
  • index.php

When I hit any URL other than the base, it gives the following error

Object Error

here is my login code

public function action_index(){ $html = new Template(); if(Session::get("logged_in")){ Response::redirect('/test-newsletter'); exit(0); } // die("in ifss"); if(Input::post()){ $username = Input::post('username',''); $password = Input::post('password',''); if($username === "username" && $password === "password") { Session::set('logged_in', true); Response::redirect('/test-newsletter'); }else{ $html->assign('message','Wrong username or password'); } } return $html->fetch('login.tpl'); } 

here are my .php routes

 <?php return array( "_root_" => "default/index", "logout" => "default/logout", "_404_" => "default/404", "time" => "default/time", "test" => "default/test", "birthdays" => "backstage/birthdays", "earned-status" => "backstage/earned_status", "nearly-new-status" => "backstage/nearly_new_status", "placed-order" => "backstage/placed_order", "user-history" => "backstage/user_history", "test-newsletter" => "backstage/test_newsletter", "preview-email" => "backstage/preview_email", "view-email/:id" => "backstage/view_email", "api/set-date" => "backstage/api_set_date" ); 

this is the backstage test object test function

 public function action_test_newsletter(){ die("here"); $submitted = Input::post("submit", false); $points = Input::post("points", ""); $email = Input::post("email", ""); $type = Input::post("type", ""); $html = new Template(); $html->assign("points", $points); $html->assign("email", $email); $html->assign("type", $type); $html->assign("message", ""); if($submitted){ $testService = new TestService(trim($type), trim($email), trim($points)); if($testService->isValid()){ $testService->processEmail(); $html->assign("message", "Email Sent!"); }else{ $html->assign("message", $testService->getErrorMesssage()); } } return $html->fetch("test_newsletter.tpl"); } 

But after logging in it will not be test_newsletter, instead it will show me an object that was not found.

** I read that we need to put .htaccess somewhere in our project, but I do not quite understand about it. Can anyone advise me **

+5
source share
1 answer

Try .htaccess in your root folder (usually public /?):

 RewriteEngine On # The following rule tells Apache that if the requested filename # exists, simply serve it. RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] # The following rewrites all other queries to index.php. The # condition ensures that if you are using Apache aliases to do # mass virtual hosting, the base path will be prepended to # allow proper resolution of the index.php file; it will work # in non-aliased environments as well, providing a safe, one-size # fits all solution. RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ RewriteRule ^(.*) - [E=BASE:%1] RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L] 
0
source

Source: https://habr.com/ru/post/1271335/


All Articles