Php 找不到404页。找不到您请求的页面。编码点火器3.0.6

Php 找不到404页。找不到您请求的页面。编码点火器3.0.6,php,.htaccess,codeigniter,model-view-controller,codeigniter-3,Php,.htaccess,Codeigniter,Model View Controller,Codeigniter 3,我发现CodeIgniter3:404页面有问题 文件:application/controllers/Welcome.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Welcome extends CI_Controller { public function __construct() { parent::__construct();

我发现CodeIgniter3:404页面有问题

文件:application/controllers/Welcome.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {   
    public function __construct()
    {
        parent::__construct();
    }
    public function index()
    {
        $this->load->view('Welcome_Page');
    }
    public function tutorial()
    {
        $this->load->view('Tutorial_Page');
    }
    public function manual()
    {
        $this->load->view('Manual_Page');
    }
    public function forum()
    {
        $this->load->view('Forum_Page');
    }
    public function register()
    {
        $this->load->view('Register_Page');
    }
    public function login()
    {
        $this->load->view('Login_Page');
    }
}
文件:application/config/routes.php

$route['default_controller'] = 'welcome';
$route['translate_uri_dashes'] = FALSE;
文件:application/config/config.php

$config['base_url'] = 'http://subdomain.domain.tld';
$config['index_page'] = '';
文件:.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
页面加载欢迎页面,但不加载其他页面

404 Page Not Found

The page you requested was not found.
在文件夹视图中,存在页面:Forum_Page.php、Login_Page.php、Manual_Page.php、Register_Page.php、Tutorial_Page.php和Welcome_Page.php


非常感谢您的理解

试试这个。将.htaccess代码替换为以下代码:YOURPROJECTNAME是您的基本文件夹。e、 g.如果您在本地服务器上,并且您的项目名为myproblem,则将“YOURPROJECTNAME”替换为“myproblem”

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* YOURPROJECTNAME/index.php/$0 [PT,L]

确保.htaccess也位于应用程序的根目录下。

试试这个。将.htaccess代码替换为以下代码:YOURPROJECTNAME是您的基本文件夹。e、 g.如果您在本地服务器上,并且您的项目名为myproblem,则将“YOURPROJECTNAME”替换为“myproblem”

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* YOURPROJECTNAME/index.php/$0 [PT,L]

确保.htaccess也位于应用程序的根目录下。

啊,我现在明白了。你的问题出在路线上。你注定要以同样的方式到达页面

http://sub.domain.tld/welcome/tutorial
http://sub.domain.tld/welcome/manual
...
但是您创建视图HTML是为了

http://sub.domain.tld/tutorial
http://sub.domain.tld/manual
...
APPPATH.config/routes.php'
文件中,在保留路由下,您必须以以下方式重新路由调用:

$config[(:any)] = 'welcome/$1'
有两件事你需要注意:

  • 占位符
    (:any)
    将在
    $1中出现
  • 包含
    (:any)
    参数的路由必须位于文件末尾,因为 路由将按定义的顺序运行。较高的路线将始终优先于较低的路线


  • 还有更多。检查整个页面以及文档中的其他页面。

    啊,我现在明白了。你的问题出在路线上。你注定要以同样的方式到达页面

    http://sub.domain.tld/welcome/tutorial
    http://sub.domain.tld/welcome/manual
    ...
    
    但是您创建视图HTML是为了

    http://sub.domain.tld/tutorial
    http://sub.domain.tld/manual
    ...
    
    APPPATH.config/routes.php'
    文件中,在保留路由下,您必须以以下方式重新路由调用:

    $config[(:any)] = 'welcome/$1'
    
    有两件事你需要注意:

  • 占位符
    (:any)
    将在
    $1中出现
  • 包含
    (:any)
    参数的路由必须位于文件末尾,因为 路由将按定义的顺序运行。较高的路线将始终优先于较低的路线


  • 还有更多。检查整个页面以及文档中的其他页面。

    显示您试图访问的URL。我试过的
    base\u-url
    中应该有一个尾随斜杠:$config['base\u-url']=''。。。不起作用。请尝试更改
    RewriteRule^(.*)$index.php?/$1[L]
    。我没有得到另一个结果:(@AurelBercea向我们显示您的实时站点地址显示您的URL试图访问。并且在
    base\u URL
    中应该有一个尾随斜杠,我尝试过:$config['base\u URL']='';不起作用。请尝试更改
    RewriteRule^(.*)$index.php?/$1[L]
    。我没有得到另一个结果:(@AurelBercea show us your live site address I displays error:500 Internal Server error发生内部服务器错误。您的应用程序是否在本地服务器上运行?否…在共享服务器上运行将代码替换为(当我在公共域上运行时,它对我有效):RewriteBase/RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d RewriteRule^(.*)$index.php?/$1[L]ErrorDocument 404/index.php I显示错误:500内部服务器错误发生内部服务器错误。您的应用程序是否在本地服务器上运行?否…在共享服务器上运行将代码替换为(当我在公共域上运行时它对我有效):RewriteBase上的RewriteEngine/RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d rewrited rule^(.*)index.php?/$1[L]ErrorDocument 404/index.php#SOreadytohelp感到自由(和向上投票),因为它修复了您的问题,帮助他人更容易找到解决方案。#SOreadytohelp感到自由(和向上投票),因为它修复了您的问题,帮助他人更容易找到解决方案。