CodeIgniter Forums
Yet (another) htacess problem - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Yet (another) htacess problem (/thread-49480.html)

Yet (another) htacess problem - El Forum - 02-21-2012

Trying to set up a CI install on a sub-domain.

$config['base_url'] = '';
$config['index_page'] = '';

.htaccess file:
<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

This works perfectly.

However, I want everything to run on SSL. So the following is changed in config.php:
$config['base_url'] = '';

And I add the following lines to the end of the htaccess file:
RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^(testing)\. [NC]
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

And then I get a 404 (not a CI 404).

Any ideas?

Yet (another) htacess problem - El Forum - 02-21-2012

I have also tried only changing the base_url to use https, and not changing the htaccess (i.e. no SSL redirect in htaccess), with the same result.

Yet (another) htacess problem - El Forum - 02-21-2012

base_url needs a trailing slash after .com.

Your SSL directives should be at the top of your htaccess file, above the CI rules. Otherwise, the request goes straight to CI and the SSL rewrite directives never get used. They get processed in order.

Yet (another) htacess problem - El Forum - 02-21-2012

Thanks for the response

Adding a trailing slash to base_url (i.e. seems to work fine.

However, if I change the base_url to (without adding any ssl rewrites to htaccess), then I get a 404

I have also tried setting the base_url = '' - in this case works fine, and still gives a 404

Yet (another) htacess problem - El Forum - 02-21-2012

Right, so it seems that a virtualhost has to be added to httpd.conf for each subdomain that is to run SSL. Hope this helps someone else out at some point in the future...