2016-05-29 186 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。我不知道你的意思是「你是如何訪問它」,但我總是通過「本地主機」訪問它。對不起,不太清楚 –