Secure Pages

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Secure Pages

Post by hexdj »

I have a couple of forms that need to go thru a SSL, my site already has an SSL. I have the pages already written in CMS MS now my question is, how do I make CMS MS automatically switch to HTTPS:// when these pages are accessed? is this even possible?. Thanks!
Last edited by hexdj on Wed Oct 03, 2007 2:33 am, edited 1 time in total.
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: Secure Pages [SOLVED]

Post by hexdj »

Ted at the chatroom pointed me to the solution, which is not built in into CMSMS. Have to edit my .htaccess file and do something like this:

RewriteRule ^/secure_page(.*) https://mysite.com/secure_page$1


EDIT:

I actually just had a chance to try this out and didn't work. Can someone gimme a hand? Thanks!

Last edited by hexdj on Wed Oct 03, 2007 2:33 am, edited 1 time in total.
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: Secure Pages

Post by hexdj »

Anyone?
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Secure Pages

Post by RonnyK »

hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: Secure Pages

Post by hexdj »

I missed that one, I will give it a try. Thanks RonnyK!
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: Secure Pages

Post by hexdj »

The method pointed out by RonnyK seems to work, except that when I am in one of my secure pages, all the links appear to point to an HTTPSS:// address, which FireFox says it can't open, because it does not how to handle it, due to the double SS in there. Also CSS Styles are gone for some reason when I get into a secure page. I looked in my files and nowhere is it expressed to point to httpss://
Last edited by hexdj on Thu Oct 04, 2007 7:15 am, edited 1 time in total.
alby

Re: Secure Pages

Post by alby »

hexdj wrote: The method pointed out by RonnyK seems to work, except that when I am in one of my secure pages, all the links appear to point to a HTTPSS:// address, which FireFox says it can't open, because it does not how to handle it, due to the double SS in there. I looked in my files and nowhere is it expressed to poing to httpss://
Check in config.php if you have:
$config['root_url'] = 'http://www.mysite.com';
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')
{
#$config['root_url'] = str_replace('http','https',$config['root_url']);
}
If yes, try comment with #

Alby
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Secure Pages

Post by tsw »

hmh, that code needs some work it seems :)
Pierre M.

Re: Secure Pages

Post by Pierre M. »

Hello all,

may be the code needs some work.
I suggest something else at the webserver level. Untested, as I have no SSL Apache at hand :

Code: Select all

RewriteEngine on
RewriteCond HTTPS off
RewriteRule ^/(.*) https://fully.qualified.domain.name/$1 [L,R]
To be tuned, because untested and unwarantied.

Pierre M.
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: Secure Pages

Post by hexdj »

Alby:

Your method seems to work, except that now my address bar in firefox is pink instead of green (secure) and the lock shows as open and when I click on the lock it says that some elements that are loaded aren't secure.

Do you have any advice for this?
alby wrote:
hexdj wrote: The method pointed out by RonnyK seems to work, except that when I am in one of my secure pages, all the links appear to point to a HTTPSS:// address, which FireFox says it can't open, because it does not how to handle it, due to the double SS in there. I looked in my files and nowhere is it expressed to poing to httpss://
Check in config.php if you have:
$config['root_url'] = 'http://www.mysite.com';
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')
{
#$config['root_url'] = str_replace('http','https',$config['root_url']);
}
If yes, try comment with #

Alby
alby

Re: Secure Pages

Post by alby »

hexdj wrote: Your method seems to work, except that now my address bar in firefox is pink instead of green (secure) and the lock shows as open and when I click on the lock it says that some elements that are loaded aren't secure.

Do you have any advice for this?
Your site is ALL on SSL connection?
If yes set (in config.php):
$config['root_url'] = 'https://www.mysite.com';

If not:
1. or disabled UDT and enable again in config.php (drop my # comment)
2. or try Pierre M. tips
3. (from tsw) that code needs some work

Alby
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: Secure Pages

Post by hexdj »

OK, I'm giving up on these methods because all of them have their own caveats.

Could someone tell me if there's any other to redirect pages with .htaccess
For example the following line doesn't work

Redirect 301 /store/ https://www.mysite.com/store/

The reason why it doesn't work is (I think) because it creates a redirecting loop. Maybe someone else know another way out of it?


UPDATE:

I turned my /store/ PAGE into a link in the Edit Content section of CMSMS,
Now this link redirects to the following: https://www.mysite/store/ssl
SSL is a child page for /store/
and now /store/ssl/ is this page should have my store

It redirects beautifully, but now here's the issue that I have: I don't want all my pages to be secured, just the store. How can I get out of the https:// protocol when clicked on any other menu in my site?
Last edited by hexdj on Wed Oct 10, 2007 8:01 pm, edited 1 time in total.
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: Secure Pages

Post by hexdj »

BEST SOLUTION SO FAR

Thanks everyone for their kind suggestions but the following method seems to be the best I have found so far, it's not ideal (at least in my case) since I had to make two templates that are almost exactily the same, except for loading different User Defined Tags.

First off I created one UDT called {https}

Code: Select all

if(empty($_SERVER['HTTPS']))
{
    // If not, redirect
    $newurl = 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
    header("location: $newurl");
    exit();
}
And a second UDT for regular pages that don't need to be secured, this one I called {http}

Code: Select all

if(empty($_SERVER['HTTPS']))
{
    // Do nothing
}
else
{
    $newurl = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
    header("location: $newurl");
    exit();
}
Now my default Layout Template is called DEFAULT_TEMP and has the {http} tag in the head section

And my secure template is called SECURE_TEMP and has the {https} tag in it

Given that my template is the same for all my pages it's a pitty having to make two virtually identical templates just to switch between http and https if I make changes to my default template I have to remember to make those changes in my secure template as well. But for now it's a quick and dirty solution and it's the one I am gonna stick with.

Hope this helps somebody else!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Secure Pages

Post by calguy1000 »

if this solution works for you, then there are ways to make it so you only have to use one page template.

One way is:

a) add {assign var='secure' value='1'} to the metadata section of your secure pages
b) use this in your page template:

Code: Select all

{if isset($secure)}
  {https}
{else}
  {http}
{/if}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: Secure Pages

Post by hexdj »

Even better! I am just not too much of a php/smarty programmer and fairly new to CMSMS

thanks calguy!!
Last edited by hexdj on Sat Jan 19, 2008 10:57 am, edited 1 time in total.
Post Reply

Return to “CMSMS Core”