【问题标题】:Codeigniter .htaccess, make public folder as rootCodeigniter .htaccess,将公用文件夹设为根
【发布时间】:2017-07-27 18:19:36
【问题描述】:

我有这样的文件和文件夹结构:

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

在 .htaccess 目录中。 1 我有:

<IfModule mod_rewrite.c>
    Options -MultiViews

 RewriteEngine on

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

在 .htaccess 目录中。 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 时,它会显示欢迎页面

你能帮我处理一下这个 .htaccess 文件吗?

谢谢。

【问题讨论】:

  • 尝试关注this example。如果不工作,您可以将您的 Web 可访问目录指向 public。 IE。 /var/www/html 让它成为 /var/www/html/public.

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


【解决方案1】:

在你的根 .htc 访问中试试这个

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

并尝试将控制器文件名的第一个字母更改为大写 所以不要控制器,而是将其重命名为控制器

【讨论】:

    猜你喜欢
    • 2012-05-09
    • 1970-01-01
    • 2021-11-20
    • 2017-10-12
    • 1970-01-01
    • 1970-01-01
    • 2015-11-11
    • 2015-03-25
    • 1970-01-01
    相关资源
    最近更新 更多