【问题标题】:Codeigniter - Setting up SSL and getting 404 errorsCodeigniter - 设置 SSL 并收到 404 错误
【发布时间】:2015-02-27 16:05:56
【问题描述】:

我已经使用this tutorial 设置了一个测试 SSL 证书。我的应用程序需要用户身份验证。正如预期的那样,我在加载登录页面时收到一条错误消息。当我尝试导航到任何其他页面或提交登录表单时,我收到 404 错误消息。

我的假设是所有的 URL,因为它们是由控制器创建的,在 .htaccess 中不再被重写。我不清楚如何解决此问题,以便我的所有 URL 都可以正常工作,而不是基本 index.php 文件。

我的服务器详情如下:

  • Apache2
  • Ubuntu 12.04
  • Codeigniter 2(2 的某些版本)

这是我的.htaccess 文件:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #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]
     RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    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>

【问题讨论】:

    标签: php apache .htaccess codeigniter ssl


    【解决方案1】:

    您需要在 apache 配置中设置 AllowOverride 指令。

    将 AllowOverride None 更改为 AllowOverride All

    Set Allow Override

    【讨论】:

    • 谢谢。这解决了这个问题。一个快速说明,以防这对任何人都有帮助,我的设置略有不同,而不是在 apache2/apache.conf 中,我不得不更改我的 apache2/sites-available/default-ssl
    猜你喜欢
    • 2020-07-16
    • 1970-01-01
    • 2015-04-12
    • 1970-01-01
    • 2015-09-19
    • 2018-03-30
    • 2015-04-06
    • 1970-01-01
    • 2014-12-23
    相关资源
    最近更新 更多