I have this really weird problem which I've already spent a lot of time investigating, but failed to find a solution.
Basically, I have a few domains parked in the server, but for simplicity, let's assume just 2 domains:
- example.co.nz (main)
- example.com
I have 2 requirements I'd like to satisfy:
- a) I want all traffic from (2) redirected to (1)
- b) I want all HTTP traffic to be redirected to HTTPS
So basically, in one sentence, I want all traffic to simply go to https://www.example.co.nz no matter what URL patterns I type into the location bar.
I have written a .htaccess file in the root like this:
SetEnv TZ
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !^on [OR]
RewriteCond %{HTTP_HOST} !^www\.example\.co\.nz
RewriteRule (.*) https://www.example.co.nz/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/(system|lib)(.*)$
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
The following works:
The following does not get redirected:
- Would anyone happen to have any ideas why this is happening?
I was wondering if this is related to my htaccess or the server itself.
Any help would be high appreciated.