HTTPS / SSL: Securing a single page (e.g. orderform)
-
The Goal:
Have wp-blog / website located on a normal URL (eg. https://www.mysite.de). BUT additionally have a subpage (maybe an orderform) that can be encrypted via ssl (eg. https://ssl-id.de/mysite.de/?page_id=16).The Problem:
Worpress uses the value of a setting called “wordpress-adress” or “blog-adress” ( which is set during the install-routine or manually in the preferences ) to embed images or css into the site.
This is leading to warnings when surfing to the encrypted orderpage due to elements not being load from the secure URL. So the user might get some warning like “everything you put in here can easily be monitored by 3rd parties”. This is not good, especially if you want them to put credit-card information in this form.The Solution:
Ok. This one is a hack. You’ll need some PHP- Knowledge. But until wp finds a better way to handle single pages that need the safe data-transfer, this is how it worked for me:1. Find the “get_option()” function.
In my case (version) it was located in a script called “functions.php” located in the “wp-includes” folder.2 Edit the return statement of get_option()
I replaced the following code:return apply_filters( 'option_' . $setting, maybe_unserialize($value) );
with
// Arnski HTTPS Fix if(strpos($_SERVER['SCRIPT_URI'], "https")===FALSE) { return apply_filters( 'option_' . $setting, maybe_unserialize($value) ); } else { return str_replace('https://www.', 'https://www.ssl-id.de/', apply_filters( 'option_' . $setting, maybe_unserialize($value) )); } //return apply_filters( 'option_' . $setting, maybe_unserialize($value) ); // End Arnski HTTPS Fix
Voilà! Now whenever customers come to the encrypted page – thus in the URL there is the “s” behind the “http” – every embedded element does get this prefix too.
Note, in this case i was using a 3rd Party Certificate from a webhost called Strato, thats why it is neccessary to prepend the URL with “https://www.ssl-id.de/”.
Have fun, kids.
Arnski
- The topic ‘HTTPS / SSL: Securing a single page (e.g. orderform)’ is closed to new replies.