2016-03-06 105 views
2

我正在爲我的網站使用codeigniter v3,並遇到從一個頁面重定向到另一個頁面的問題。PHP - Codeigniter URL無法在沒有index.php的情況下工作 - 找不到對象

如果我單擊該選項卡,鏈接顯示localhost:8080/IDS/view/decisiontree並顯示Object not found! The requested URL was not found on this server...

如果我編輯的URL並使其localhost:8080/IDS/index.php/view/decisiontree,該網站完全負載。

這裏是我的路線:

$route['view/decisiontree'] = 'data_controller/goto_decisiontree'; 

下面是相關的標籤的代碼:

<li><a href="<?php echo base_url();?>view/decisiontree">Decision Tree</a></li> 

這裏是我的data_controller:

public function goto_decisiontree(){ 
    $data['page'] = "2"; 

    $this->load->view('decisiontree_page', $data); 
} 

這裏是我config.php

$config['base_url'] = 'http://localhost:8080/IDS'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 

這裏是我的.htaccess:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

,並注意,我用笨V3。

非常感謝您的幫助!

+0

只是說明在基本URL的提出結束斜線'/''$配置[ 'BASE_URL'] = '的http://本地主機:8080/IDS /';' – user4419336

+0

你使用的是wamp還是xampp等? – user4419336

回答

1

請嘗試以下

打開config.php並做以下內容替換

$config['index_page'] = "index.php" 

$config['index_page'] = "" 

在某些情況下,uri_protocol默認設置無法正常工作。只需更換

$config['uri_protocol'] ="AUTO" 

通過

$config['uri_protocol'] = "REQUEST_URI" 

的.htaccess

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

希望它能幫助。

+1

codeigniter中沒有Auto uri協議3 – user4419336

+1

已經嘗試過這個,它不工作:( – achll

0

在您的codeIgniter項目的主目錄中試試htaccess。它似乎在xampp和wamp中工作正常。

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

的config.php

$config['base_url'] = 'http://localhost:8080/IDS/'; 
$config['index_page'] = ""; 
$config['uri_protocol'] = 'REQUEST_URI'; 

所有的方式記住,你應該有文件名稱和類的第一個字母爲大寫,其餘小寫。refer

更多htaccess的例子here

+0

仍然不工作:( – achll

相關問題