CodeIgniter Forums
.htaccess on an https server - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: .htaccess on an https server (/showthread.php?tid=79044)



.htaccess on an https server - goobydale - 04-12-2021

I am using codeigniter 3.1.11 for a school project. Locally, I have set-up this .htacces file

Code:
<IfModule mod_rewrite.c>
# deny from all
RewriteEngine On

RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d

RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>

With these settings :

PHP Code:
$config['base_url'] = 'http://localhost/codeigniter';

$config['index_page'] = '';

$config['uri_protocol']    = 'REQUEST_URI'
 
Locally, the rules work (i.e: localhost/codeigniter/welcome) takes me to the welcome page.

However, these same rules, do not work on the student server provided by my school.
Even after I have adapted everything, I still need to put index.php in the URL

PHP Code:
$config['base_url'] = 'https://'.$_SERVER['SERVER_NAME'].'/codeigniter'

If i try to access the welcome controller the same way I did locally, I only get back
Code:
File not found.

on the browser.

The servername follows this logic : studentNumber.SCHOOL_SERVER.com (connected via school vpn)

Any ideas?
Thanks


RE: .htaccess on an https server - josephgodwinke - 04-12-2021

The baseurl should have a trailing slash:

`$config['base_url'] = 'http://localhost/codeigniter/';`

use absolute path on production like this: `'http://school_server.com/codeigniter/';`