How to change WordPress permalink structure from a plugin

Dynamically changing the wordpress permalink structure from a plugin based on if the site is viewed with SSL / HTTPS or normally.

This works in with this post: How to get WordPress working on Shared SSL

The shared ssl hosting link does not allow .htaccess mod_rewrite, however the normal wordpress url does allow mod_rewrite. This means the good permalink structure works on the normal website, but it does not work on the shared ssl version of the website. This causes 404 errors when trying to navigate the SSL website. BAD!

To fix this, add this code to your themes functions.php file:

add_action('pre_option_permalink_structure','dtbaker_permalink_hack');
function dtbaker_permalink_hack(){
  if(is_ssl()){
    return '';
  }
  return false;
}

Leave a Reply

Your email address will not be published. Required fields are marked *