Why is it redirecting?

Sometimes a redirect will keep happening, even if you have deleted the redirect or disabled Redirection. It’s easy to think that Redirection is responsible for all the redirects on your site, but this is not the case, and redirects can come from many other places.

  • Cache – Your browser or your server may have cached a redirect. Clearing your cache usually solves this
  • Another plugin – other plugins can cause redirects too
  • WordPress – WordPress itself can also cause redirects, for various reasons
  • Server configuration – redirects in .htaccess and Nginx can override everything

If you disable Redirection then it is not running and is not redirecting your site.

How can I tell if Redirection is the cause?

  1. Go to https://redirect.li/http/ and enter your URL
  2. Look through the HTTP headers for x-redirect-agent 
  3. If the header isn’t present then Redirection is not responsible for the redirect

How can I work out what is causing the redirect?

It’s a little tricky.

If you think WordPress or a plugin is performing the redirect you can follow these steps to find out the cause. Note that this is fairly advanced and you need to be comfortable editing files on your server.

  1. Create a new file in your wp-content/plugins folder called redirect-debug.php
  2. Edit this file and copy/paste one of the following. If you pick the ‘Shouty Redirect Debug’ it will show information in your browser. This will affect all redirects across the whole of your WordPress, and may not be suitable for a production site. If you pick the ‘Quiet Redirect Debug’ then it will output the information to your PHP error log. It won’t show anything on your site, but you will need access to your error log.
<?php

/*
Plugin Name: Shouty Redirect Debug
Description: Show all redirects
Version: 0.1
*/

add_filter( 'wp_redirect', function( $url ) {
  echo '<pre>';
  print_r( debug_backtrace() );
  echo '</pre>';
} );
<?php

/*
Plugin Name: Quiet Redirect Debug
Description: Show all redirects
Version: 0.1
*/

add_filter( 'wp_redirect', function( $url ) {
  error_log( print_r( debug_backtrace(), true ) );
} );

3. Go to your plugins menu and activate the newly created plugin

4. Trigger the redirect and you will see a lot of information (either in your browser or in the PHP error log) about what functions are running. This should indicate what plugin or what part of WordPress the problem lies with.

search previous next tag category expand menu location phone mail time cart zoom edit close