Welcome Guest, Not a member yet? Register   Sign In
Yet (another) htacess problem
#1

[eluser]JonoB[/eluser]
Trying to set up a CI install on a sub-domain.

application/config/config.php:
Code:
$config['base_url'] = 'http://testing.mysite.com';
$config['index_page'] = '';

.htaccess file:
Code:
<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]
</IfModule>

This works perfectly.

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

And I add the following lines to the end of the htaccess file:
Code:
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?
#2

[eluser]JonoB[/eluser]
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.
#3

[eluser]CroNiX[/eluser]
base_url needs a trailing slash after .com. http://testing.mysite.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.
#4

[eluser]JonoB[/eluser]
Thanks for the response

Adding a trailing slash to base_url (i.e. http://testing.mysite.com/) seems to work fine.

However, if I change the base_url to https://testing.mysite.com/ (without adding any ssl rewrites to htaccess), then I get a 404

I have also tried setting the base_url = '' - in this case http://testing.mysite.com works fine, and https://testing.mysite.com still gives a 404
#5

[eluser]JonoB[/eluser]
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...




Theme © iAndrew 2016 - Forum software by © MyBB