This page will install redirect rules to fix Google Search Console redirect issues.
ID);\n // Remove any parameters from canonical URL\n $canonical = strtok($canonical, \’?\’);\n echo \’\’ . “\n”;\n }\n}\nadd_action(\’wp_head\’, \’add_canonical_tags\’, 1);\n\n// Prevent indexing of parameter URLs\nfunction noindex_parameter_urls() {\n $current_url = $_SERVER[\’REQUEST_URI\’];\n \n if (strpos($current_url, \’?amp=\’) !== false || \n strpos($current_url, \’?noamp=\’) !== false || \n strpos($current_url, \’&=\’) !== false || \n strpos($current_url, \’&noamp=\’) !== false) {\n echo \’\’ . “\n”;\n }\n}\nadd_action(\’wp_head\’, \’noindex_parameter_urls\’, 1);\n?>’;
// Write the plugin file
$result = file_put_contents($mu_plugin_dir . ‘redirect-fix.php’, $plugin_content);
if ($result !== false) {
echo ‘
‘;
echo ‘
The plugin will now handle:
‘;
echo ‘
- ‘;
- Redirect AMP URLs (?amp=1) to clean URLs
- Redirect noamp URLs (?noamp=mobile) to clean URLs
- Redirect product copy URLs to correct products
- Redirect old shop URLs to new product URLs
- Add proper canonical tags
- Add noindex to parameter URLs
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
echo ‘
This will fix the Google Search Console redirect errors.
‘;
} else {
echo ‘
‘;
}
}
else {
echo ‘
‘;
echo ‘
This will fix the Google Search Console “Page with redirect” errors by:
‘;
echo ‘
- ‘;
- Handling AMP URL redirects properly
- Removing parameter-based URLs from indexing
- Fixing product URL redirects
- Adding proper canonical tags
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
}
?>