【发布时间】:2015-05-22 03:12:42
【问题描述】:
我多次测试我的网站,但我无法解决“找不到页面”错误。 嗯,
1 步:我创建一个控制器并调用welcomelogin.php - 我存储两个函数
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class WelcomeLogin extends CI_Controller {
public function index()
{
$this->home();
}
public function home(){
$this->load->helper('url');
$this->load->view('login');
}
public function inside(){
$this->load->helper('url');
$this->load->view('inside');
}
2- 步骤:在我的 rote.php 文件中,我简单地执行以下操作:
$route['default_controller'] = "welcomeLogin";
$route['404_override'] = '';
3- 步骤:在视图文件夹中我创建了两个文件,一个是 login.php,第二个是 inside.php,其中 login.php 包含登录表单, inside.php 包含简单的 html。
现在我将登录页面作为我网站的主页,它工作正常: http://localhost/website/Codeigniter_Project/MyProject/
当我执行以下操作时,我得到页面未找到错误: 我尝试了两种方法,都给了我同样的错误:
第一种方式:直接给出视图名称和结果页面未找到 本地主机/网站/Codeigniter_Project/MyProject/inside
第二种方式:通过给出控制器名称然后查看但未找到结果页面 localhost/website/Codeigniter_Project/MyProject/welcomelogin(controllername)/inside
请帮助我,因为我花了将近 2 个小时搜索和应用不同的答案,是的,堆栈上有类似的问题,有些答案我已经尝试过但没有奏效,这些问题与我的有点不同。谢谢你们的时间。:) 我在 localhost 服务器上运行,我的 apache mod_rewrite 已打开。谢谢。 &我是codeigniter的新手,谢谢
我的 .htaccess 文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /website/Codeigniter_Project/MyProject/
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]
# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
###
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
【问题讨论】:
-
base_url 呢?
-
inside - 不工作
标签: php codeigniter