【问题标题】:Codeigniter link to load different viewCodeigniter 链接以加载不同的视图
【发布时间】:2013-11-03 04:40:22
【问题描述】:

我不确定我在这里做错了什么。一切看起来都很好。但我在页面加载时不断收到错误 500。

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Site extends CI_Controller {
    public function index() 
    {
        $this->home();
    }

public function home()
    {
        $this->load->view("header");
        $this->load->view("site");
        $this->load->view("footer");
    }

public function about()
    {
        $this->load->view("header");
        $this->load->view("about");
        $this->load->view("footer");
    }
}

如果我去链接 mywebsite.com/site/about

我会收到 500 内部服务器错误

我做错了什么?

我的 htaccess 文件是这样的

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|scripts|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

想法?想法。我知道这很愚蠢。我已经有几个月没有做过任何 CI 工作了。

谢谢

【问题讨论】:

  • 请检查文件名和文件夹结构

标签: php .htaccess codeigniter


【解决方案1】:

我发现了问题所在。这与 htaccess 文件有关

我必须这样做才能让它工作

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

谢谢

【讨论】:

    【解决方案2】:

    1) 您的 CI 文件夹是位于根文件夹中还是位于“站点”文件夹中?

    2) 如果在“站点”文件夹中,请尝试使用 mywebsite.com/site/your_controller_name/about 也可以试试 mywebsite.com/index.php/site/about 或 mywebsite.com/site/index.php/your_controller_name/about

    我如何称呼它:mywebsite.com/CodeIgniter/Welcome/About
    CI 文件位于“CodeIgniter”文件夹中,这就是我的 .httaccess 的样子:http://pastebin.com/30TReyqe

    【讨论】:

    • about.php 文件位于我的视图目录中。这也是我的 site.php 文件加载良好的地方。就在我想加载 about.php 文件时,我得到了一个奇怪的错误。
    • 好吧,我发现问题出在哪里。在本地使用 WAMP 一切正常。但是在我的托管公司(godaddy)上它不起作用。有什么想法吗?
    • 一件事500错误码并不代表文件不存在,如果文件不存在,应该是404或者400范围内的代码。如果大概是 500 范围,则需要与服务器端配置有关。比如内存需要在php文件中分配等等。
    • @menukadevinda 对不起,我发帖时才醒来。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-07
    • 2014-10-18
    • 2013-01-10
    • 2013-03-18
    • 1970-01-01
    • 2014-02-18
    相关资源
    最近更新 更多