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

1.我将config.php中的base_url更改为

https://localhost/codeignitor.

http://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://localhost/codeignitor/index.php/my_site

很好。

===============>>#1 票数:1 已采纳

似乎在您的https服务器配置中未读取.htaccess,并且您使用的是LAMP(Apache),因此请转到https的服务器配置位置,例如default-ssl或httpd-ssl.conf,并确保打开AllowOverride。 如果您不在线,则需要添加它。

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

  ask by Karthik translate from so

未解决问题?本站智能推荐: