To offer your customer SSL (https) in a WebsiteBaker website there was, until now, only one solution: put the complete website in SSL mode.
The problem with using SSL in parts of the site is that show_menu2 creates menu's using the default WB_URL value of WebsiteBaker. There can be only one value: http:// or https://.
The next problem is that all linked elements in a page like images, stylesheets and javascripts should be loaded trough SSL to. If not there will be security warnings about mixed (secure/unsecure) content.
Using a droplet these problems can be solved, and it can allow you to use some pages using a secure link while others are using normal http protocol.
The Dropletcode (call it "securelink"):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | //call the droplet like: if (!isset( $path )) return true; $linkfind = WB_URL. $path ; $wb_page_data = str_replace ( $linkfind , $linkreplace , $wb_page_data ); if ( $_SERVER [ 'SERVER_PORT' ]!==80) { $linkfind = WB_URL.MEDIA_DIRECTORY; $wb_page_data = str_replace ( $linkfind , $linkreplace , $wb_page_data ); $linkfind = WB_URL. '/modules' ; $wb_page_data = str_replace ( $linkfind , $linkreplace , $wb_page_data ); $linkfind = TEMPLATE_DIR; $wb_page_data = str_replace ( $linkfind , $linkreplace , $wb_page_data ); } return true; |
The droplet will rewrite all generated links within the given path (?path=directoryname) to its https equivalent.
Next, if the current page is loaded through a secure connection, all url's of images (media folder) templates and modules (i.e. frontend.css and frontend.js) will be rewritten to their https equivalent.
The droplet should be placed in you template so it will be executed on every page load.
An example call for the droplet would be: . Using that all pages in the webshop structure should work using https connections.
Often a webshop will start using a page of the menu-link type to redirect users to the first category of the shop.
Normally you select a page from a dropdown list to where the visitor should be redirected. Menu-link does not know about https, so it will redirect the visitor to the http version of the first page.
This can be fixed by using a few lines in a httaccess in the root of your website. The htaccess will rewrite all requests for a defined folder to https.
The htaccess rules:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} pages/webshop
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Obviously you will need to have a valid, signed, SSL certificate installed on your server.
Your hoster should be able to help you with that.
A live website with this solution can be seen on www.deguts.nl