I have an URL which is 301 redirecting but I cannot find where or how it is happening and wanted some checks to perform if possible?

  • I've checked .htaccess - it's not there
  • I've checked cPanel in redirects section - it's not there
  • In WordPress, I have the redirection plugin active and it's not there either

Is there anywhere else that could be issuing redirects? I'm at a loss to find out where and how the page is redirecting!

  • Do you have specific directory .htacess files? Sometimes there are multiple copys on different directory levels. – Switchfire Oct 18 '13 at 8:09
  • If it's not in any of those you've mentioned, it's likely being controlled in a .php file somewhere. Try disabling the WP plugin though just to be sure and then see if the URL is still redirecting. – zigojacko Oct 18 '13 at 11:35
  • What is the URL question redirecting to? Is it going off-site or from one page/post to another? – JCL1178 Oct 19 '13 at 5:55

Any of the following can cause redirects:

  • .htaccess files (cPanel usually edits one of these files)
  • Apache configuration files (usually httpd.conf)
  • In code (such as a plugin) that sets a Location: header.

To locate the source of redirects, I usually search all the source code using recursive grep on the command line. I usually search for the URL of the redirect.

URLs can be stored in the database as well (some WordPress plugins might do that), so it would be good to look there as well.

If it is malware that hacked your site and caused the redirect, the URL may be obfuscated in the source code to make finding it harder.


I just had this happen, took me a while to find the setting but if you are using Plesk then check this setting from Plesk Panel.

Navigate to Home > Subscriptions > yourdomain.com > Websites & Domains > yourdomain.com > Hosting Settings. Then check "Preferred domain" dropdown you can choose www. or domain.

  • I've been caught out by this 'feature' in Plesk a few times. Lucky I found this answer here to remind me the of the cause of the problem. Choose 'None' in "Preferred domain" dropdown to stop Plesk doing any redirection. It is unfortunate that this is not the the default setting. – AidanCurran May 15 '17 at 20:43

If you are using CloudFlare purge cache and switch to development mode.

Some cache plugins can do redirects as well. Better empty the cache directory.

Theme plugins might have some weird issues as well.

Making a backup and deleting plugin directories one by one can help to find bad apples easily. (In case the logs aren't helpful.)

Maybe this saves some hours for someone.


This issue was caused by a .htaccess file in a parent directory. This parent had iThemes Security plugin which had inserted some code into htaccess to block execution of the file: install.php which was filtering down to all sub-directories.


If using WordPress, place this WordPress filter in theme or plugin code to stack dump. This only works if the redirect is triggering through one of the WordPress helper functions like wp_safe_redirect.

add_filter( 'wp_redirect', function($url) { var_export(debug_backtrace()); } );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.