2015-11-26 51 views

回答

0

不要離開自己的基本網址空白

$config['base_url'] = 'http://localhost/ci/'; 

那就試試這個htaccess的

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] 

而且自動加載的url幫手application > config > autoload.php

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

而且你不需要有控制器?>在端

<?php 

class Home extends CI_Controller { 

    function index(){ 
     echo base_url(); 
    } 

} 
0

插入網址在​​你的配置如下圖所示:

$config['base_url'] = 'http://localhost/ci/'; 

添加下面的代碼在你的應用程序>配置> autoload.php

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

並更換的.htaccess通過以下腳本刪除來自url的index.php。

的.htaccess

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteBase/
RewriteCond $1 !^(index\.php|assets|uploaded_files|img_cache|jscal|robots\.txt|favicon\.ico) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /ci/index.php?/$1 [L,QSA] 
</IfModule> 

之後,你的URL將被http://localhost/ci/home

+0

刪除'從第一線的RewriteCond system'。 – Tpojka

相關問題