2016-05-29 125 views
0

我是一个完整的初学者CodeIgniter,一般框架,我尝试过Laravel和CakePHP,但都是非常复杂的安装(对我来说),所以现在我已经下载CI,它看起来很简单,除了此访问被拒绝错误。CodeIgniter错误403

错误是默认的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叙述在

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ index.PHP/$1 [L]  

,它给了我一个403错误(这是不是默认的Firefox错误)和它只是说“目录访问被禁止”。

+0

只需访问http:// localhost/codeigniter – Fil

+0

我做了,它的工作原理。但我想要做的是进入“应用程序”目录。 –

+0

你不能这样做,它必须是'http://example.com/ [controller-class]/[controller-method]/[arguments]'方式 – Fil

回答

1

笨的安装非常简单

  1. 解压缩软件包。
  2. 将CodeIgniter文件夹和文件上传到您的服务器。通常index.php文件将在你的根目录下。
  3. 使用文本编辑器打开application/config/config.php文件并设置您的基本URL。如果您打算使用加密或会话,请设置您的加密密钥 。
  4. 如果您打算使用数据库,请使用文本编辑器打开application/config/database.php文件并设置您的 数据库设置。
从文档 https://codeigniter.com/user_guide/installation/index.html

在你的application/config/config.php文件进行设置这样

$config['base_url'] = 'http://'. $_SERVER['HTTP_HOST'] .'/your_project/'; 

一旦你做了,访问您的网站

http://localhost/your_project/index.php

Tha T的所有

如果你想访问你自己的控制器

http://example.com/[controller-class]/[controller-method]/[arguments] 

例子:

http://example.com/your_project/index.php/your_controller

删除的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> 
+0

仍然有这个错误。 “目录访问被禁止”。 –

+0

你正在使用什么服务器以及如何访问它? – Fil

+0

我正在使用XAMPP。我不知道你的意思是“你是如何访问它”,但我总是通过“本地主机”访问它。对不起,不太清楚 –