我是CodeIgniter的完全初学者,一般是Frameworks,我尝试过Laravel和CakePHP,但两者都非常复杂(对我而言)所以现在我已经下载了CI,看起来很简单,除了这个访问被拒绝错误。
错误是默认的Firefox 403(访问被拒绝)错误。它说:
You don't have permission to access the requested object. It's either read-protected or not readable by the server.
当我转到localhost/codeigniter/application
我的基本网址:http://localhost/codeigniter/application
。我不知道为什么我这样设置,但似乎合乎逻辑。
更新:编辑htaccess文件后,使其如下所示: `RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.PHP/$1 [L]
,它给了我另一个403错误(这不是默认的Firefox错误),它只是说“目录访问被禁止”。
答案 0 :(得分:4)
codeigniter的安装非常简单
- 解压缩包裹。
- 将CodeIgniter文件夹和文件上传到您的服务器。通常,index.php文件将位于您的根目录。
- 使用文本编辑器打开application / config / config.php文件并设置基本URL。如果您打算使用加密或会话,请设置 你的加密密钥。
- 如果您打算使用数据库,请使用文本编辑器打开application / config / database.php文件并设置 数据库设置。
醇>
来自文档https://codeigniter.com/user_guide/installation/index.html
你的application / config / config.php中的make设置如下
$config['base_url'] = 'http://'. $_SERVER['HTTP_HOST'] .'/your_project/';
完成后,访问您的网站
http://localhost/your_project/index.php
这就是全部
如果您想访问自己的控制器
http://example.com/[controller-class]/[controller-method]/[arguments]
示例:
删除index.php,编辑你的.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /your_project/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
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.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>