Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 为codeigniter项目强制使用https_.htaccess_Codeigniter_Codeigniter 2 - Fatal编程技术网

.htaccess 为codeigniter项目强制使用https

.htaccess 为codeigniter项目强制使用https,.htaccess,codeigniter,codeigniter-2,.htaccess,Codeigniter,Codeigniter 2,我希望我的整个网站下的https。所以我做了两件事: 1.我将config.php中的基本url更改为 https://localhost/codeignitor. 从 2.我更改的.htaccess文件: DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|images|css|codeignitor|include|js|robots\.txt|favicon\.ico) RewriteCond

我希望我的整个网站下的https。所以我做了两件事:

1.我将config.php中的基本url更改为

https://localhost/codeignitor.

2.我更改的.htaccess文件:

DirectoryIndex index.php

RewriteEngine on

RewriteCond $1 !^(index\.php|images|css|codeignitor|include|js|robots\.txt|favicon\.ico)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ ./index.php/$1 [QSA]

# The following two lines newly added

RewriteCond %{HTTPS} off # To redirect all the http to https

RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301]
但是当我访问

http://localhost/codeignitor/mysite
这是我的错误[尽管它被重定向到https]

Not Found

The requested URL /codeignitor/my_site was not found on this server.
但是


工作正常。

似乎。https服务器配置中未读取htaccess,您正在使用LAMP(Apache),因此请转到https的服务器配置位置,例如默认ssl或httpd-ssl.conf,并确保AllowOverride已打开。如果您不知道该行,则需要添加该行

<Directory /your/directory/to/codeigniter/>
    AllowOverride all
</Directory>

允许超越所有

我在“codeignitor”看到一个潜在的打字错误,谢谢,实际上是codeignitor。我对它进行了编辑。我认为可能是您的https服务器配置设置不正确,您是否可以检查在使用https时是否读取了您的.htaccess文件?是否在本地主机上的https下加载了静态文件?像Codeigniter之外的图像或文本文件?您正在使用XAMPP或类似的捆绑安装程序?您在同一个CI安装下运行了多个站点?在添加这一行并重新启动apache;)之后,我使其正常工作。非常感谢。
https://localhost/codeignitor/index.php/my_site
<Directory /your/directory/to/codeigniter/>
    AllowOverride all
</Directory>