[pmwiki-users] V2 SSL Mode? (was Re: Unable to save...)

H. Fox haganfox at users.sourceforge.net
Thu Nov 16 16:36:43 CST 2006


On 11/16/06, L. Bell <labellz at earthlink.net> wrote:
> There was a V1 Cookbook recipe called "SwitchToSSLMode".  I think
> that recipe evolved from a thread on this list in April, 2004.
> (Excerpts from two key emails and the V1 Recipe provided below, for
> reference.)

I've learned a lot since I wrote that recipe.  FWIW here's what I'm using now:

   if (!$_SERVER["HTTPS"] == 'on') {
     header("Location: https://www.example.com/wiki/");
     exit('<html><body>
       <a href="https://www.example.com/wiki/">Please use SSL.</a>
       </body></html>');
   }

and later in config.php:

   if ($_SERVER["HTTPS"] == 'on') {
     $ScriptUrl = "https://www.example.com/wiki";
     $PubDirUrl = 'https://www.example.com/wiki/wiki/pub';
   } else {
     $ScriptUrl = "http://www.example.com/wiki";
     $PubDirUrl = 'http://www.example.com/wiki/wiki/pub';
   }

The wiki I grabbed this from is in a farm and it uses "clean URLs" so
$ScriptURL and $PubDirUrl may not look the same for a generic
installation.  I put the second group of lines in there so the site
will work with or without SSL.  That way I can comment out the
force-to-SSL part and have the site work properly.

> 2) Why doesn't the SwitchToSSLMode recipe appear in the V2 cookbook?

Many reasons, but it seems like now is a good time to add it, so I just did.

   http://www.pmwiki.org/wiki/Cookbook/SwitchToSSLMode

Hagan




More information about the pmwiki-users mailing list