1

我有問題CodeIgniter3:404未找到網頁404頁未找到。未找到您所請求的頁面。笨3.0.6

文件:應用/控制器/的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'); 
    } 
} 

文件:應用/配置/自動加載/ PHP的

$autoload['helper'] = array('url'); 

文件:應用程序/配置/ routes.php文件

$route['default_controller'] = 'welcome'; 
$route['translate_uri_dashes'] = FALSE; 

文件:應用程序/配置/ 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] 

頁負荷Welcome_Page,而不是其他的網頁。

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

非常感謝您的理解!

+0

顯示您的URL嘗試訪問。 ''base_url'應該有一個斜線' –

+0

我試過了:$ config ['base_url'] ='http://subdomain.domain.tld/'; ...不工作。 – Aurel

+0

嘗試改變'RewriteRule ^(。*)$ index.php?/ $ 1 [L]'。 – Tpojka

回答

0

啊,我明白了。你的問題在路由中。你是爲了達到頁面作爲

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' 

這裏有兩件事你需要注意:

  1. 佔位符(:any)將採取地方$1
  2. 你包含(:any)參數航線必須在文件中,因爲

    Routes will run in the order they are defined. Higher routes will always take precedence over lower ones.

更是here的結束。檢查文檔中的整個頁面和其他頁面。

+0

謝謝!作品! :D – Aurel

+0

#SOreadytohelp隨意[接受](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)(和upvote),因爲它解決了您的問題以幫助他人更容易找到解決方 – Tpojka

5

試試這個。用以下代碼替換您的.htaccess代碼:YOURPROJECTNAME是您的基本文件夾。例如如果你是在本地服務器上,你的項目被稱爲myproblem,然後用「myproblem」取代「爲yourprojectname」

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

保證的.htaccess是在您的應用程序的根也。

+0

我顯示錯誤: 500 內部服務器錯誤 內部服務器錯誤發生。 – Aurel

+0

是在本地服務器上運行的應用程序? – Dunco

+0

沒有...共享服務器 – Aurel