Forum
SSL code configuration where to put it?
Where does this code go to force ssl on all pages and can it be used to force ssl to the non or www address?
<?php PerchSystem::force_ssl(); ?>
Where does this code go to force ssl on all pages and can it be used to force ssl to the non or www address?
<?php PerchSystem::force_ssl(); ?>
Hi Carol,
I believe the idea behind that function was to enable only certain pages to be forced to SSL. If you're looking to make the whole site use SSL, then investigate using Apache/your choice of webserver to handle it.
Hello Carol,
Check out this post from the Perch Blog: Perch and SSL
Alternatively, you can force SSL via your .htaccess file like so:
The advantage of handling this with
PerchSystem::force_ssl()
instead of .htaccess is SSL doesn't have to be forced in all your environments (dev, staging and production). This point is also discussed in the blog post linked above.I need something that will take the www address to the non www secure address. Will your code do that>Hussein Al Hammad said: >
Could you clarify further?
If I'm understanding you correctly, you want to redirect
https://www.example.com
tohttps://example.com
. Is this correct?Yes and https://www.example.com to https://example.com
In your .htaccess file, you can use the following:
This should remove
www
and force SSL for all pages.Note that this solution doesn't utilise
PerchSystem::force_ssl()
so you probably need different .htaccess file for each environment (dev, staging and production).Thanks