Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter 3.0.htaccess不工作_Php_.htaccess_Codeigniter_Codeigniter 3 - Fatal编程技术网

Php CodeIgniter 3.0.htaccess不工作

Php CodeIgniter 3.0.htaccess不工作,php,.htaccess,codeigniter,codeigniter-3,Php,.htaccess,Codeigniter,Codeigniter 3,我有一个.htaccess文件,用于Codeigniter 2.2.0,在控制器中使用子目录时效果良好。但是在Codeigniter 3.0中,我无法通过链接访问我的网站 尽管如此,以下链接仍然有效: 我的路线很明确 $route['default_controller'] = 'frontend/home/index'; 和我的.htaccess Options -Indexes Options +FollowSymLinks # Set the default file for i

我有一个
.htaccess
文件,用于Codeigniter 2.2.0,在控制器中使用子目录时效果良好。但是在Codeigniter 3.0中,我无法通过链接访问我的网站

尽管如此,以下链接仍然有效:

我的路线很明确

 $route['default_controller'] = 'frontend/home/index';
和我的
.htaccess

Options -Indexes
Options +FollowSymLinks

# Set the default file for indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>

    # activate URL rewriting
    RewriteEngine on

    # do not rewrite links to the documentation, assets and public files
    RewriteCond $1 !^(index\.php|public|robots\.txt)

    # do not rewrite for php files in the document root, robots.txt or the maintenance page
    RewriteCond $1 !^([^\..]+\.php|robots\.txt|sitemap\.xml)

    # but rewrite everything else
    RewriteRule ^(.*)$ 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.

    ErrorDocument 404 index.php

</IfModule>
选项-索引
选项+FollowSymLinks
#设置索引的默认文件
DirectoryIndex.php
#激活URL重写
重新启动发动机
#不要重写指向文档、资产和公共文件的链接
1美元^(索引\.php | public | robots\.txt)
#不要在文档根、robots.txt或维护页面中重写php文件
1美元^([^\..]+\.php | robots\.txt | sitemap\.xml)
#但是重写其他的一切
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
ErrorDocument 404 index.php

在使用codeigniter 3.0的
$route['default\u controller']
上,您不能再使用子文件夹

这是CI2中的一个bug,它允许您将文件夹放在默认路径中

对于
$route['default\u controller']
控制器必须位于如下所示的主控制器位置

任何其他控制器仍可以有子文件夹,但默认控制器必须位于控制器的第一级

application

application > controllers 

application > controllers > Home.php
注意:您需要将类的第一个字母和文件名设置为大写,如下所示

Routes.php

$route['default_controller'] = 'home/index';
如果您需要在codeigniter 3中使用带有
$route['default\u controller']
的子文件夹,我建议您使用HMVC,这将允许您在routes中具有
$route['default\u controller']
中的子文件夹

注:HMVC仅适用于CI3

在godaddy中,所有控制器类的第一个字母必须为大写。在codeigniter 3.0中100%工作->

比如: 应用程序>控制器>Home.php