Codeigniter .htaccess,将公用文件夹设为root

时间:2017-03-07 13:48:20

标签: .htaccess codeigniter mod-rewrite codeigniter-3

我有这种文件和文件夹结构:

framework
-- app
---- cache
---- config
---- controllers
---- models
---- ....
-- system
public
-- assets
---- css
---- js
---- ...
-- uploads
-- .htaccess (2)
.htaccess (1)

在.htaccess nr。 1我有:

<IfModule mod_rewrite.c>
    Options -MultiViews

 RewriteEngine on

 RewriteRule  ^$ public/    [L]
    RewriteRule  ((?s).*) public/$1 [L]
</IfModule>

在.htaccess nr。 2我有:

<IfModule mod_rewrite.c>
 RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^((?s).*)$ index.php/$1 [QSA,L]
</IfModule>

问题是:

  1. 当我访问127.0.0.1时,它给出了CI错误404

  2. 当我访问127.0.0.1/public时,它会显示欢迎页面

  3. 你可以帮我解决这个.htaccess文件吗?

    感谢。

1 个答案:

答案 0 :(得分:0)

在您的root .htc访问

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

并尝试将您的控制器文件名首字母更改为大写字母 所以代替控制器,将其重命名为Controller