Plugin Directory

Changeset 1930152


Ignore:
Timestamp:
08/25/2018 12:01:26 PM (8 years ago)
Author:
rehmatworks
Message:

Updating to version 1.5

Location:
wp-ssl-redirect
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • wp-ssl-redirect/tags/1.5/readme.txt

    r1913243 r1930152  
    44Requires at least: 3.95
    55Tested up to: 4.9
    6 Stable tag: 1.4
     6Stable tag: 1.5
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2222
    2323= How does WP SSL Redirect perform the redirect? =
    24 The plugin makes use of $_SERVER array to check either the URL is accessed over HTTPS or HTTP. If the request is made over HTTP, then the plugin sends a 301 redirect header and performs the redirect to the HTTPS version of the same URL.
     24The plugin makes use of <code>$_SERVER</code> array to check either the URL is accessed over HTTPS or HTTP. If the request is made over HTTP, then the plugin sends a 301 redirect header and performs the redirect to the HTTPS version of the same URL.
    2525
    2626= 301 Redirect is Not Working =
    27 If <code>WP_SITEURL</code> and <code>WP_HOME</code> are defined in your WordPress website's <code>wp-config.php</code> file, then uncomment or delete these two constants, otherwise WP SSL Redirect's 301 redirect may not work properly.
     27If <code>WP_SITEURL</code> and <code>WP_HOME</code> are hardcoded in your WordPress website's <code>wp-config.php</code> file, then uncomment or delete these two constants, otherwise WP SSL Redirect's 301 redirect may not work properly.
    2828
    2929== Screenshots ==
     
    4343* Rewrote the redirection code to make it even simpler
    4444* Disabled the website URL update in the database
     45== 1.5 ==
     46* Bug fixes
  • wp-ssl-redirect/tags/1.5/wp-ssl-redirect.php

    r1913238 r1930152  
    44* Plugin Name: WP SSL Redirect
    55* Description: A very tiny plugin to force SSL on WordPress websites (via 301 redirects for SEO purpose).
    6 * Version: 1.4
     6* Version: 1.5
    77* Author: Rehmat Alam
    88* Author URI: https://supportivehands.net/
     
    6464}
    6565
     66function rw_has_www($url)
     67{
     68  return (bool) (strpos($url, '://www') !== false);
     69}
     70
    6671function do_the_ssl_redirect() {
    6772  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    6873  if(!is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php')) {
    69     $redirectUrl = "https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
     74    $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
     75    $ori_url = rtrim($scheme . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", '/');
     76    $redirectUrl = $ori_url;
    7077    if(get_option('wp_ssl_redirect_protocol') == 'www') {
    71       if(strpos($redirectUrl, '//www.') === false) {
    72         $redirectUrl = str_replace('://', '://www.', $redirectUrl);
     78      if(!rw_has_www($ori_url)) {
     79        $redirectUrl = str_replace('://', '://www.', $ori_url);
    7380      }
    7481    } else if(get_option('wp_ssl_redirect_protocol') == 'non-www') {
    75       if(strpos($redirectUrl, '//www.') !== false) {
    76         $redirectUrl = str_replace('//www.', '//', $redirectUrl);
     82      if(rw_has_www($ori_url)) {
     83        $redirectUrl = str_replace('//www.', '//', $ori_url);
    7784      }
    7885    }
    79    
    80     if(empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] !== "on") {
    81       header('Location: '.$redirectUrl, true, 301);
     86    $redirectUrl = rtrim(str_replace('http://', 'https://', $redirectUrl), '/');
     87    if($ori_url !== $redirectUrl)
     88    {
     89      wp_redirect($redirectUrl, 301);
    8290      exit;
    8391    }
  • wp-ssl-redirect/trunk/readme.txt

    r1913243 r1930152  
    44Requires at least: 3.95
    55Tested up to: 4.9
    6 Stable tag: 1.4
     6Stable tag: 1.5
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2222
    2323= How does WP SSL Redirect perform the redirect? =
    24 The plugin makes use of $_SERVER array to check either the URL is accessed over HTTPS or HTTP. If the request is made over HTTP, then the plugin sends a 301 redirect header and performs the redirect to the HTTPS version of the same URL.
     24The plugin makes use of <code>$_SERVER</code> array to check either the URL is accessed over HTTPS or HTTP. If the request is made over HTTP, then the plugin sends a 301 redirect header and performs the redirect to the HTTPS version of the same URL.
    2525
    2626= 301 Redirect is Not Working =
    27 If <code>WP_SITEURL</code> and <code>WP_HOME</code> are defined in your WordPress website's <code>wp-config.php</code> file, then uncomment or delete these two constants, otherwise WP SSL Redirect's 301 redirect may not work properly.
     27If <code>WP_SITEURL</code> and <code>WP_HOME</code> are hardcoded in your WordPress website's <code>wp-config.php</code> file, then uncomment or delete these two constants, otherwise WP SSL Redirect's 301 redirect may not work properly.
    2828
    2929== Screenshots ==
     
    4343* Rewrote the redirection code to make it even simpler
    4444* Disabled the website URL update in the database
     45== 1.5 ==
     46* Bug fixes
  • wp-ssl-redirect/trunk/wp-ssl-redirect.php

    r1913238 r1930152  
    44* Plugin Name: WP SSL Redirect
    55* Description: A very tiny plugin to force SSL on WordPress websites (via 301 redirects for SEO purpose).
    6 * Version: 1.4
     6* Version: 1.5
    77* Author: Rehmat Alam
    88* Author URI: https://supportivehands.net/
     
    6464}
    6565
     66function rw_has_www($url)
     67{
     68  return (bool) (strpos($url, '://www') !== false);
     69}
     70
    6671function do_the_ssl_redirect() {
    6772  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    6873  if(!is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php')) {
    69     $redirectUrl = "https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
     74    $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
     75    $ori_url = rtrim($scheme . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]", '/');
     76    $redirectUrl = $ori_url;
    7077    if(get_option('wp_ssl_redirect_protocol') == 'www') {
    71       if(strpos($redirectUrl, '//www.') === false) {
    72         $redirectUrl = str_replace('://', '://www.', $redirectUrl);
     78      if(!rw_has_www($ori_url)) {
     79        $redirectUrl = str_replace('://', '://www.', $ori_url);
    7380      }
    7481    } else if(get_option('wp_ssl_redirect_protocol') == 'non-www') {
    75       if(strpos($redirectUrl, '//www.') !== false) {
    76         $redirectUrl = str_replace('//www.', '//', $redirectUrl);
     82      if(rw_has_www($ori_url)) {
     83        $redirectUrl = str_replace('//www.', '//', $ori_url);
    7784      }
    7885    }
    79    
    80     if(empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] !== "on") {
    81       header('Location: '.$redirectUrl, true, 301);
     86    $redirectUrl = rtrim(str_replace('http://', 'https://', $redirectUrl), '/');
     87    if($ori_url !== $redirectUrl)
     88    {
     89      wp_redirect($redirectUrl, 301);
    8290      exit;
    8391    }
Note: See TracChangeset for help on using the changeset viewer.