Codeigniter - 设置SSL并获得404错误

时间:2014-12-31 15:47:52

标签: php apache .htaccess codeigniter ssl

我使用this tutorial设置了测试SSL证书。我的应用需要用户认证。正如所料,我在加载登录页面时收到错误消息。当我尝试导航到任何其他页面或提交登录表单时,我收到404错误消息。

我的假设是,由控制器创建的所有URL都不会在.htaccess中重写。我不清楚如何解决此问题,以便我的所有网址都与基础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>

1 个答案:

答案 0 :(得分:3)

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

将AllowOverride None更改为AllowOverride All

Set Allow Override