I want my whole site under https. So I did two things:

1.I changed my base_url in the config.php to

https://localhost/codeignitor.

from

http://localhost/codeignitor.

2.My changed .htaccess file:

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]

But when I visit

http://localhost/codeignitor/mysite

this is my error [Though it get redirected to https]

Not Found

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

But

https://localhost/codeignitor/index.php/my_site

is woking fine.

有帮助吗?

解决方案

Seems .htaccess is not read in your https server config and you're using LAMP (Apache) so please go to your server config location for https, e.g. default-ssl or httpd-ssl.conf, and make sure AllowOverride is turned on. If you don't the line, you will need to add that.

<Directory /your/directory/to/codeigniter/>
    AllowOverride all
</Directory>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top