Welcome Guest, Not a member yet? Register   Sign In
Redirect doesn't work with SSL
#1

We have a basic website built with CodeIgniter. There are 4 pages altogether. We recently moved to SSL certificate and the website doesn't redirect properly
in .htaccess we have the standard directives to access pages without /index.php/
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Since we moved to https all links stopped working eg. www.example.com/home doesn't work anymore. But if you access the page with www.example.com/index.php/home it works!!!

Is there anything else I need to write in the htaccess file? Or any other way to fix the redirects?
Reply
#2

(04-11-2017, 05:33 AM)ghost13 Wrote: We have a basic website built with CodeIgniter. There are 4 pages altogether. We recently moved to SSL certificate and the website doesn't redirect properly
in .htaccess we have the standard directives to access pages without /index.php/
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Since we moved to https all links stopped working eg. www.example.com/home doesn't work anymore. But if you access the page with www.example.com/index.php/home it works!!!

Is there anything else I need to write in the htaccess file? Or any other way to fix the redirects?

The virtualhost config is wrong. the config of you https is missing an AllowOverride.
Reply
#3

Did you edit config.php and put the "https: in base_url?
Reply
#4

I change https in base_url config.php but still no change.
I don't know where to put this AllowOverride and what is the correct syntax
Currently in our ssl.config file I have

#<VirtualHost *:80>
#DocumentRoot /path/to/site/
#ServerName www.example.com
#Redirect permanent / https://www.example.com/
#</VirtualHost>

#<VirtualHost *:443>
#DocumentRoot /path/to/site/
#ServerName www.example.com
#SSLEngine on
#SSLCertificateFile /root/www_example_com.crt
#SSLCertificateKeyFile /root/www_example_com.key
#SSLCertificateChainFile /root/certificate.crt
#</VirtualHost>

Lines are commented because otherwise this website redirects to out other website.
Reply
#5

(This post was last modified: 04-14-2017, 04:24 AM by dave friend.)

I think your RewriteRule  is malformed.

Change
Code:
RewriteRule .* index.php/$0 [PT,L]
to
Code:
RewriteRule ^(.*)$ index.php/$1 [L]

I don't think the PT flag was of any benefit and I removed it.

There is a very handy htaccess tester at http://htaccess.mwl.be/

Given a test URL of http://example.com/controller that site outputs http://example.com/index.php/controllerindex.php/

With my rule the output is http://example.com/index.php/controller
Reply
#6

(This post was last modified: 04-14-2017, 02:32 AM by InsiteFX. Edit Reason: add for changes )

You can add it to vhosts like this:

Code:
# CI 3.1.4 Dev CSD Testing
<VirtualHost *:80>
   DocumentRoot "\xampp\htdocs\citest\public_html"
   ServerName citest.dev
   <Directory "\xampp\htdocs\citest\public_html">
       Order allow,deny
       Allow from all
       AllowOverride All
       Require all granted
   </Directory>
</VirtualHost>

You will want to change some of these for a live web server, this is for a localhost.

Or in your .htaccess like this:

Code:
AllowOverride All

hope this helps you out.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(04-14-2017, 02:30 AM)InsiteFX Wrote:
Code:
AllowOverride All
 
Yes thank you InsiteFX, that did the trick. I just needed to add it to the <VirtualHost *:80>
Reply
#8

@ghost13: apache has a documentation
https://httpd.apache.org/docs/2.4/en/mod...owoverride
http://httpd.apache.org/docs/current/mod...write.html
http://httpd.apache.org/docs/current/mod...l#Override

Quote:Only available in <Directory> sections

AllowOverride is valid only in <Directory> sections specified without regular expressions, not in <Location>, <DirectoryMatch> or <Files> sections.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB