且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

HTTPS并在CodeIgniter上删除index.php

更新时间:2023-02-21 22:28:12

注意:SSL重写应该在.htaccess文件中的index.php重写之前进行.

Note: The SSL rewrite should happen before the index.php rewrite in your .htaccess file.

因此,请勿执行此设置(因为我们不会更改服务器apache配置文件中的任何内容. )

So, Don't do this setting (as we don't change anything in server apache config file. )

AllowOverride All

AllowOverride All

只需应用设置2 即可.

我也遇到了同样的问题,并通过添加

I have faced the same issue and resolved it by adding

AllowOverride All

AllowOverride All

设置1: 仅供参考,我们有2个配置文件.

Setting 1: FYI we have 2 config files.

  1. 默认的Apache配置(与http一起运行)
  2. SSL配置(与https一起运行)

转到SSL配置并添加

<Directory "/var/www/html">
   AllowOverride All
</Directory> 

**设置2:**.htaccess文件应如下所示……

**Setting 2:**The .htaccess file should be like this...

RewriteEngine On
RewriteCond %{HTTPS} !=on      
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
</IfModule> 

对我有用.