[wp-hackers] Duplicate Content Issue - URLs work with dots and colons in it

Baki Goxhaj banago at gmail.com
Wed Sep 18 10:35:41 UTC 2013


Here is the solution I came up with to fix that strange behaviour:

/**
 * Fix for urls ending in dots and colons
 */
function redirect_dotted() {
	global $wp;
	$current_url = home_url( $wp->request );
	$is_dot = substr($current_url, -1, 1);
	if( $is_dot === '.' || $is_dot === ':' ) {
		$clean_url = rtrim( $current_url, '.:' );
		wp_redirect( $clean_url, 301 ); exit;
	}
	return;
}
add_action('wp', 'redirect_dotted');


Kindly,

Baki Goxhaj
about.me/banago


More information about the wp-hackers mailing list