2017-10-06 136 views
1

我正在codeigniter 3.1.6上工作。Codeigniter 3.1.6 - 如何从url中删除index.php

我添加了.htaccess文件。 我也将base_url路径更改为我的项目路径,从index_page中删除index.php,并将url_protocol更改为REQUEST_URI

尽管我将url重定向到任何控制器方法,但它将错误报告为'The page you requested was not found'。

我也搜索和应用不同的.htaccess,但它不工作。 如果我在base_url结尾添加/index.php,那么它的工作,但它的错误。它应该工作没有index.php。只有3.1.6给这个问题。

注:笨-3.1.4正常工作只有这个版本是给一个问题

+2

[笨3取出的index.php问题]的可能的复制(https://stackoverflow.com/questions/20169545/codeigniter-3-remove-index-php-problems) –

+0

但不工作,根据那些回应。这就是为什么我在这里发布 –

+0

试试这个问题的答案。然后让我知道我会帮你确定的。 –

回答

1

更改文件夹名称CodeIgniter-3.1.6ci

设置你base_url

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

使用此.htaccess

RewriteEngine On 
RewriteBase /ci 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
+0

令人敬畏的兄弟,它的工作原理。但这一切还在继续?死于缺少'RewriteBase/ci'?对于其他版本,我还没有使用这样的线仍然他们工作正常?怎么样? –

0

1)编辑的config.php

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

$config['index_page'] = '’; 

2)创建/编辑.htaccess文件

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
+0

不工作bro。已经做到了。只有这个版本给出了一个问题。我第一次使用这个版本 –

2

使用这个脚本在.htaccess

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading 
    # slashes. 
    # If your page resides at 
    # http://www.example.com/mypage/test1 
    # then use 
    # RewriteBase /mypage/test1/ 
    RewriteBase/
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system) 

    RewriteRule ^(.*)$ index.php?/$1 [L] 
    # If your root folder is at /mypage/test1/ 
    RewriteRule ^(.*?)$ /mypage/test1/index.php?/$1 [L] 

</IfModule> 

<IfModule !mod_rewrite.c> 
# If we don't have mod_rewrite installed, all 404's 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin 

    ErrorDocument 404 /index.php 
</IfModule> 

删除index.phpconfig.php $config['index_page'] = '';

+0

不工作@星期日 –