domain mapping bug with fix
-
The current version of this plugin (2.1.2) assumes that the active protocol and domain name are exactly the same in the original/from and destination/to URLs. This is a pretty significant bug, as it limits the usability to only about 25% of the possible URLs for any given “from” URL. That is, it doesn’t consider http vs https, nor www vs wwwithout. It will only allow redirecting “https://www.example.com/blog/old” to something like “https://www.example.com/blog/new”, regardless of whatever the current preferred domain & path (home_url) are, even if it’s now something like “https://example.org/“
The problem is that the code relies on home_url or manual composition to build the URLs instead of parsing them as strings. This is fixed by modifying two functions, format_from_url and get_url, in eps-301-redirects.php. Here’s the revised code to fix it:
private function format_from_url( $string ) { $complete = home_url() . '/' . $string; list($uprotocol,$uempty,$uhost,$from) = explode( '/', $complete, 4); $from = '/' . $from; return strtolower( rtrim( $from, '/') ); }
function get_url() { return strtolower( urldecode( $_SERVER['REQUEST_URI'] ) ); }
- The topic ‘domain mapping bug with fix’ is closed to new replies.