Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
找不到对象!在Fuel php中重定向路由后_Php_Redirect_Fuelphp - Fatal编程技术网

找不到对象!在Fuel php中重定向路由后

找不到对象!在Fuel php中重定向路由后,php,redirect,fuelphp,Php,Redirect,Fuelphp,下面是我的fuelphp项目的目录结构 燃料 日志 公开的 tmp 在公用文件夹中,我有 资产 index.php 当我点击除基本URL以外的任何URL时,它会抛出以下错误 找不到对象错误 这是我的登录码 public function action_index(){ $html = new Template(); if(Session::get("logged_in")){ Response::redirect('/test-newsletter');

下面是我的fuelphp项目的目录结构

  • 燃料
  • 日志
  • 公开的
  • tmp
在公用文件夹中,我有

  • 资产
  • index.php
当我点击除基本URL以外的任何URL时,它会抛出以下错误

找不到对象错误

这是我的登录码

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');

  }
这是我的routes.php

<?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"
);
但登录后,它不会测试_时事通讯,而是向我显示未找到的对象错误


**我已经读到我们需要把.htaccess放在我们项目的某个地方,但我不清楚这一点。有人能帮我**

在您的web根文件夹(通常为public/?)中尝试此
.htaccess


通常,
.htaccess
文件放置在您的
文档根路径中-在您的情况下,这应该是
公共路径
。为了验证您是否确实需要一个
.htaccess
尝试将
index.php
添加到您的路径中,如
index.php/test
或其他内容,看看您这次是否得到了实际响应。@Artamiel我也遇到了同样的问题。我在文件夹的根目录上添加了.htaccess。我已经创建了一个虚拟主机(使用xampp)。除主url外,没有其他url正在工作。它在所有url上抛出错误。我的mod_重写正在进行。htaccess看起来像RewriteBase/web_manage/public RewriteCond%&123上的RewriteEngine;请求_FILENAME}-f第二个百分点和第123个百分点;请求_FILENAME}-重写规则^(/)?$index.php/$1[L]RewriteRule^(.*)$index.php/$1[L]@awaisgarni您正在运行哪个版本的FuelPHP?我刚刚下载了上一个稳定的
1.8.0
,只需在我的
www
中提取归档文件,无需进一步配置。只需加载
localhost/fuel/public/hello
(这是一条默认路径)就可以得到一个结果。再次下载源代码,并查看项目附带的
.htaccess
文件,然后再试一次。FuelPHP附带的.htaccess文件工作正常,因此如果您有自己的文件,这显然是候选文件。特别是如果使用“未找到对象”,您指的是标准的Apache404错误。您可以在此处下载最新的.htaccess:
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");
  }
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]