CodeIgniter错误403 [英] CodeIgniter error 403

查看:197
本文介绍了CodeIgniter错误403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CodeIgniter(一般来说是Frameworks)的一个完整的初学者,我尝试过Laravel和CakePHP,但两者的安装都非常复杂(对我来说),因此,我现在下载了CI,看起来很简单,除了拒绝访问错误.

I'm a complete beginner in CodeIgniter, Frameworks in general, and I tried Laravel and CakePHP but both are very complex to install (for me) so now I've downloaded CI and it looks pretty simple except for this access denied error.

该错误是默认的Firefox 403(拒绝访问)错误.它说: You don't have permission to access the requested object. It's either read-protected or not readable by the server.

The error is the default Firefox 403(access denied) error. It says: You don't have permission to access the requested object. It's either read-protected or not readable by the server.

这种情况发生在我去localhost/codeigniter/application

我的基本URL:http://localhost/codeigniter/application.我不知道为什么要这样设置,但似乎合乎逻辑.

My base URL: http://localhost/codeigniter/application. I don't know why I set it like that but it seemed logical.

更新:在我编辑htaccess文件以使其看起来像这样之后: `RewriteEngine开启

UPDATE: After I edit the htaccess file to make it look like this: ` RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

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

,它给了我另一个403错误(这不是Firefox的默认错误),它只是说禁止目录访问".

, it gave me another 403 error (which isn't the default Firefox error) and it simply says "Directory access is forbidden".

推荐答案

codeigniter的安装非常简单

The installation of codeigniter is very simple

  1. 解压缩软件包.
  2. 将CodeIgniter文件夹和文件上传到您的服务器.通常,index.php文件将位于您的根目录.
  3. 使用文本编辑器打开application/config/config.php文件并设置基本URL.如果您打算使用加密或会话,请设置 您的加密密钥.
  4. 如果要使用数据库,请使用文本编辑器打开application/config/database.php文件并设置您的 数据库设置.
  1. Unzip the package.
  2. Upload the CodeIgniter folders and files to your server. Normally the index.php file will be at your root.
  3. Open the application/config/config.php file with a text editor and set your base URL. If you intend to use encryption or sessions, set your encryption key.
  4. If you intend to use a database, open the application/config/database.php file with a text editor and set your database settings.

从文档 https://codeigniter.com/user_guide/installation/index.html

在您的application/config/config.php中进行如下设置

in your application/config/config.php make setting like this

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

完成后,访问您的网站

http://localhost/your_project/index.php

仅此而已

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

If you want to access your own controller

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

示例:

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

要删除index.php,请编辑.htaccess

to remove index.php, edit your .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>

这篇关于CodeIgniter错误403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆