Doc WordPress WordPress Tricks, Tips & Snippets

12Oct/150

Disable automatic redirect to site url

By default WordPress redirects incoming links automatically to the proper URL based on the site url, e.g. it would redirect incorrect incoming "www." URLs automatically to the correct form, as set in the site url setting. For example: when a requested URL is "http://yourdomain.com/whatever/" but the site-url is set as "http://www.yourdomain.com" WordPress will automatically redirect the visitor to "http://www.yourdomain.com/whatever/".

This is a good thing as search engines consider www. and non-www. as different URLs and this would otherwise lead to duplicate content. But should you for whatever reason wish to disable this behaviour you can easily do so by just adding this snippet to your theme's function.php:


remove_action('template_redirect', 'redirect_canonical');

Please note: this will also disable canonical redirects!

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.