2015-11-26 54 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

相关问题