Welcome Guest, Not a member yet? Register   Sign In
Installing SSL for codeigniter
#1

(This post was last modified: 04-08-2020, 09:44 AM by jreklund.)

Dear All,

I have just installed SSL for my site. and put following in htaccess for redirection.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

Now home page is working fine, but when i tried to open Admin Page or any other page it gives 404 error.

then i removed above code from htaccess and try open manually by writing **redacted**, then its working absolutely fine for all pages.

Please guide me accordingly.
Thanks
Reply
#2

Hi, try the following instead.
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    # Force HTTPS.
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Remove the www
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</IfModule>
Reply
#3

(This post was last modified: 04-10-2020, 04:51 AM by jreklund.)

Make sure that $config['base_url'] is using the https protocol, for example

PHP Code:
$config['base_url'] = 'https://example.com/'
Reply
#4

I did the same as above provided instructions. but same error. as home page is working fine but all other pages showing 404 error.
Reply
#5

404 errors should not be due to SSL, does them work without HTTPS?
Reply
#6

(04-17-2020, 12:46 PM)jreklund Wrote: 404 errors should not be due to SSL, does them work without HTTPS?

Yes site is working will without https.
even if i addressed manually type site name with "https" then site working well. but if i made a change in htaccess file then error is coming only
.
Reply
#7

Can you post your complete .htaccess, to see if you have multiple entries of the same thing.
Reply
#8

(This post was last modified: 04-21-2020, 03:19 AM by jreklund.)

(04-20-2020, 09:14 AM)jreklund Wrote: Can you post your complete .htaccess, to see if you have multiple entries of the same thing.
below you can htaccess file code for **redacted**
Code:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Reply
#9

(This post was last modified: 01-16-2024, 06:32 AM by lorsz.)

Hi,

I have installed SSL on my server.

In config.php file I changed $config['base_url'] = 'http://doc.example.com/'; to $config['base_url'] = 'https://doc.example.com/'; and $config['index_page'] = 'index.php'; to $config['index_page'] = ''; to remove index.php from URL.
Unfortunately URLs for HTTPS requests except of home page do not work properly. As a result URLs like https://doc.example.com/page1 return "page to found".
My .htaccess


Code:
<IfModule mod_rewrite.c>
RewriteEngine On

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Options -Indexes


I use CI v3.1.11.

Could someone please help me?

UPDATE
Setting AllowOverride All in apache2.conf solved the problem.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB