【问题标题】:403 error when access controller in subfolder (CodeIgniter)访问子文件夹中的控制器时出现 403 错误 (CodeIgniter)
【发布时间】:2012-06-04 07:31:42
【问题描述】:

这是我的应用程序框架:

application
    controllers
        backend
            [backend_controllers_here]
        [frontend_controllers_here]
    models
        [shared_models_for_both_backend_and_frontend]
    views
        backend
            [backend_views_here]
        [frontend_views_here]
    ...
system
index.php
.htaccess

这是我的 .htaccess 文件内容:

Options -Indexes
Options +FollowSymLinks

# Set the default file for indexes
# DirectoryIndex index.php

<IfModule mod_rewrite.c>

    # activate URL rewriting
    RewriteEngine on

    # do not rewrite links to the documentation, assets and public files
    RewriteCond $1 !^(images|assets|uploads|captcha)

    # do not rewrite for php files in the document root, robots.txt or the maintenance page
    RewriteCond $1 !^([^\..]+\.php|robots\.txt)

    # but rewrite everything else

    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.

    ErrorDocument 404 index.php

</IfModule>  

当我在地址栏输入类似这样的内容(对于前端)时,这没有错:

  • mysite.local
  • mysite.local/index.php
  • mysite.local/index.php/frontend_controller
  • mysite.local/frontend_controller

但是对于后端,我在尝试访问时遇到了 403 错误

  • mysite.local/backend
  • mysite.local/backend/some_backend_controller

但是,在 URL 中使用 index.php 一切都很好。

  • mysite.local/index.php/backend
  • mysite.local/index.php/backend/some_backend_controller

我错过了什么吗?

感谢您的宝贵时间!

【问题讨论】:

    标签: .htaccess codeigniter controller http-status-code-403 subdirectory


    【解决方案1】:

    检查后端文件夹的权限。它可能会阻止网络服务器读取目录的实际内容。 该权限应允许所有人阅读

    【讨论】:

    • 这显然不是问题,因为它适用于 index.php。这可能是 url 重写规则的问题,它不期望这个用例。
    【解决方案2】:

    你的 config/routes.php 是什么样的?可以试试这样的:

    $route['backend'] = "backend/controller/method";
    

    【讨论】:

      猜你喜欢
      • 2015-03-01
      • 1970-01-01
      • 2015-11-04
      • 2011-11-29
      • 2012-06-24
      • 1970-01-01
      • 2017-05-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多