我是 CodeIgniter、一般框架的完全初学者,我尝试了 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]
Run Code Online (Sandbox Code Playgroud)
,它给了我另一个 403 错误(这不是默认的 Firefox 错误),它只是说“目录访问被禁止”。
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 中进行这样的设置
$config['base_url'] = 'http://'. $_SERVER['HTTP_HOST'] .'/your_project/';
Run Code Online (Sandbox Code Playgroud)
完成后,访问您的网站
http://localhost/your_project/index.php
就这样
如果您想访问自己的控制器
http://example.com/[controller-class]/[controller-method]/[arguments]
Run Code Online (Sandbox Code Playgroud)
例子:
要删除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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
51129 次 |
| 最近记录: |