Changeset 1930152
- Timestamp:
- 08/25/2018 12:01:26 PM (8 years ago)
- Location:
- wp-ssl-redirect
- Files:
-
- 2 edited
- 3 copied
-
tags/1.5 (copied) (copied from wp-ssl-redirect/trunk)
-
tags/1.5/readme.txt (copied) (copied from wp-ssl-redirect/trunk/readme.txt) (3 diffs)
-
tags/1.5/wp-ssl-redirect.php (copied) (copied from wp-ssl-redirect/trunk/wp-ssl-redirect.php) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/wp-ssl-redirect.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-ssl-redirect/tags/1.5/readme.txt
r1913243 r1930152 4 4 Requires at least: 3.95 5 5 Tested up to: 4.9 6 Stable tag: 1. 46 Stable tag: 1.5 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 22 22 23 23 = How does WP SSL Redirect perform the redirect? = 24 The plugin makes use of $_SERVERarray 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.24 The 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. 25 25 26 26 = 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.27 If <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. 28 28 29 29 == Screenshots == … … 43 43 * Rewrote the redirection code to make it even simpler 44 44 * 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 4 4 * Plugin Name: WP SSL Redirect 5 5 * Description: A very tiny plugin to force SSL on WordPress websites (via 301 redirects for SEO purpose). 6 * Version: 1. 46 * Version: 1.5 7 7 * Author: Rehmat Alam 8 8 * Author URI: https://supportivehands.net/ … … 64 64 } 65 65 66 function rw_has_www($url) 67 { 68 return (bool) (strpos($url, '://www') !== false); 69 } 70 66 71 function do_the_ssl_redirect() { 67 72 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 68 73 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; 70 77 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); 73 80 } 74 81 } 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); 77 84 } 78 85 } 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); 82 90 exit; 83 91 } -
wp-ssl-redirect/trunk/readme.txt
r1913243 r1930152 4 4 Requires at least: 3.95 5 5 Tested up to: 4.9 6 Stable tag: 1. 46 Stable tag: 1.5 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 22 22 23 23 = How does WP SSL Redirect perform the redirect? = 24 The plugin makes use of $_SERVERarray 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.24 The 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. 25 25 26 26 = 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.27 If <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. 28 28 29 29 == Screenshots == … … 43 43 * Rewrote the redirection code to make it even simpler 44 44 * Disabled the website URL update in the database 45 == 1.5 == 46 * Bug fixes -
wp-ssl-redirect/trunk/wp-ssl-redirect.php
r1913238 r1930152 4 4 * Plugin Name: WP SSL Redirect 5 5 * Description: A very tiny plugin to force SSL on WordPress websites (via 301 redirects for SEO purpose). 6 * Version: 1. 46 * Version: 1.5 7 7 * Author: Rehmat Alam 8 8 * Author URI: https://supportivehands.net/ … … 64 64 } 65 65 66 function rw_has_www($url) 67 { 68 return (bool) (strpos($url, '://www') !== false); 69 } 70 66 71 function do_the_ssl_redirect() { 67 72 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 68 73 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; 70 77 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); 73 80 } 74 81 } 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); 77 84 } 78 85 } 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); 82 90 exit; 83 91 }
Note: See TracChangeset
for help on using the changeset viewer.