php - Codeigniter - 设置 SSL 并收到 404 错误

标签 php apache .htaccess codeigniter ssl

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

我的假设是,所有 URL 由于是由 Controller 创建的,因此不会再在 .htaccess 中重写。我不清楚如何解决此问题,以便除基本 index.php 文件之外的所有 URL 都能正常工作。

我的服务器详细信息如下:

  • Apache 2
  • 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>

最佳答案

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

将“AllowOverride None”更改为“AllowOverride All”

Set Allow Override

关于php - Codeigniter - 设置 SSL 并收到 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27723284/

相关文章:

php - MYSQL错误结果输出

apache - 如何在日志文件中添加时间戳

php - mod_rewrite 与永久重定向

php - Laravel Excel 垂直居中对齐

php - 如何使用 php 的 password_hash() 方法..?

php - 单击链接时更改页面语言

apache - 是否可以不将 Tomcat 与 apache http 服务器集成并向部署在 Tomcat 中的 servlet 发出 @Injectable 请求?

.htaccess - 带有 .htaccess 的 SEO 友好 URL

php - Htaccess 使用 FastCGI 重写

apache - 将文件 url 重定向到 .htaccess 中的另一个页面