Index.php does not remove https CodeIgniter

index.php is not deleted, but I use https , but it works for http. I need my site to work correctly, for example, it works on http and https . Anyone who has encountered the same problem will help me fix this.

Example: in http

In https

1) https://xyz.mydomain.com/users/login // 404 pages not found
2) https://xyz.mydomain.com/index.php/users/login // works great

MY htaccess code

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

config.php My base url is set as

 $root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST']; $root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $config['base_url'] = $root; 
+8
php codeigniter .htaccess
source share
1 answer

There seems to be a problem in your host file. If you are using apache, modify your host file, for example:

 <VirtualHost *:443> ServerAdmin admin@example.com DocumentRoot /path ServerName xyz.mydomain.com ServerAlias www.xyz.mydomain.com SSLEngine On SSLOptions +StrictRequire SSLCertificateFile /path to ssl file/mydomain.crt SSLCertificateKeyFile /path to ssl file/mydomain.key SSLProtocol TLSv1 <Directory "/path"> Require all granted Options -FollowSymLinks -Includes -ExecCGI -Indexes AllowOverride All Order allow,deny Allow from all </Directory> RewriteEngine On </VirtualHost> 

Now select the htaccess file, for example:

 <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://xyz.mydomain.com/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> 

Happy coding :)

+1
source

All Articles