HTTPS并在CodeIgniter上删除index.php [英] HTTPS and Remove index.php on CodeIgniter

查看:118
本文介绍了HTTPS并在CodeIgniter上删除index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用codeigniter框架,设置.htaccess文件以删除index.php,并尝试为服务器启用HTTPS协议,

I am using codeigniter framework,set .htaccess file to remove index.php and trying to enable HTTPS protocol for the server, and something happened.

HTTP:

  1. 一切正常,当我访问 http://www.example.com/controller/method http://www.example.com/index.php/controller/method

HTTPS:

  1. 一切正常,当我访问 https://www.example.com/ index.php /controller/method

  1. Everything is okay, when I access https://www.example.com/index.php/controller/method

当我访问 https://www.example.com/controller/时,找不到404代码方法

我认为这是.htaccess文件问题,看起来htaccess文件不适用于HTTPS协议.

I think that is .htaccess file problem, it is look like htaccess file not working for HTTPS protocol.

我网站的.htaccess文件.

.htaccess file of my site.

DirectoryIndex index.php
RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]

出问题了吗?非常感谢.

Is something wrong? thanks a lot.

推荐答案

注意: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> 

对我有用.

这篇关于HTTPS并在CodeIgniter上删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆