Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php

20,413

Warren,

First of all, delete the codes you inserted in your wp-config.php. Instead, put it before your the require_once(ABSPATH . ‘wp-settings.php’):

define( 'WP_HOME','http://warrenmaginn.com' );
define( 'WP_SITEURL','http://warrenmaginn.com' );
define( 'TEMPLATEPATH','/home/MYUSER/public_html/wp-content/themes/MYTHEME' );
define( 'STYLESHEETPATH','/home/MYUSER/public_html/wp-content/themes/MYTHEME' );

If your website uses SSL, don't add any rules to wp-config or htaccess because it may result in 500 internal server error. To force the use of SSL, install "Really Simple SSL" and clear your htaccess, leaving only the necessary:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Now, go to your php settings and set error_reporting as "E_ALL" and verify what the logs says (if you want to fix it by the hard way).

But you can go to your file manager and change the plugin folder name to "plugin.old". It will say if there are any plugins causing the problem. If it is, you could disable each plugin to discover which one is giving you this headache.

If plugins is not the real cause, I'd try to upload a fresh version of your Wordpress (you can find it here ~~ https://wordpress.org/download/). Remember to rename wp-admin and wp-includes to wp-admin.old and wp-includes.old, respectively before unzip the fresh ones. Don't forget to delete all the root folder WP files except wp-config.php.

I'm looking forward to receive your answer.

Share:
20,413
Warren G
Author by

Warren G

Updated on July 19, 2021

Comments

  • Warren G
    Warren G almost 3 years
    • When I try logging in to wp-admin (or even wp-admin/index.php) I simply get redirected to my site's homepage. (after authenticating successfully - i.e. It DOES accept my login credentials (so its not an account, password or blacklisting issue), but simply wont go to the admin dashboard page after login) (I suspect it may be an infinite loop that is occurring?? - how do I find out?)

    • But I CAN login if I go directly to the wp-login.php page, which is weird. (but this is not acceptable as I need users to be able to login through a custom login page again)

    • This came about seemingly randomly (I hadnt changed anything in a week - just woke up one day and couldnt log in)

    • Preceding factors:

      • I havent moved the site at all
      • I havent changed the domain, urls or anything
      • no cache-ing plugins present

    The week before I had: Updated WP to 4.8 Updated PHP from 5.4 to 5.6 (to allow installation of an SEO plugin add-on - 'SEO framework extension manager')

    But it had been working fine for days.

    • So to given some reporting this after PHP upgrade, I tried setting my PHP back to 5.4, but no luck.
    • then up to 5.5, and then back up to 5.6 again - still no fix.

    I do also have a membership plugin that renames the login page to /login (But that has worked fine for years too)

    I have tried all the usual fixes for wp-admin login issues: - I have tried multiple browsers, and cleared their cache and cookies - no fix. - I have disabled every plugin one by one (via ftp folder rename) - no fix. - even re-updated WordPress to 4.8 again (in case any of the core files needed replacing)

    • checked file and folder permission are all correct (644) via FTP - all fine - no fix.

    • I have tried adding lines to the wp-config.php file - with no luck Such as

    define('WP_HOME','https://warrenmaginn.com');

    define('WP_SITEURL',... etc.

    define('FORCE_SSL_ADMIN', true);

    define('FORCE_SSL_LOGIN', true);

    even this solution offered at kinocreative: @define('ADMIN_COOKIE_PATH', '/');

    • when I remove the htaccess file altogether, still no fix (but I do actually get a 404 error page whenever I try access any other page than the root domain, when I dont have the htaccess in place) (which may mean something in the htaccess i needed to correctly link in my site - but my htaccess hasnt changed, and if I edit it down just to the canonical rewrites (I use SSL sitewide, and do not ever use www in any references to my domain (have checked across database etc.)

    • I have tried inserting the text "die(FILE':'.LINE);" on every line of the wp-admin/index.php file (to trouble shoot it - and it stopped (without redirecting) even after placing the line all the way at the bottom of the file - so I imagine this means the issue is not in this file)

    • Any other files I should try this in?

    • Or debug modes I can use track this down?

    Any suggestions would be VERY appreciated (this is doing my head in)

    Thanks in advance for offering your wisdom...

  • Warren G
    Warren G almost 7 years
    Thanks for your response. But can you pls clarify a couple of things: 1. that SSL plugin seems to add htaccess code to do its work anyway (and Id rather not add any more plugins - plus SSL was working sitewide for over a year now - here is the basic portion in my htaccess 'RewriteCond %{HTTPS} !=on [NC] RewriteRule ^/?(.*) warrenmaginn.com/$1 [R=301,NC,L] # END Sitewide HTTPS RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]' And where are the PHP settings you said (in the htaccess or the php.ini)
  • Igor Araújo
    Igor Araújo almost 7 years
    Really Simple SSL will add some rules to your htaccess, but you can delete it and the plugin will work normally. If you use cPanel, you can find the PHP setting in "PHP Selector" or php.ini. If you want to do the things faster, I'd say to follow the last steps I gave.
  • Warren G
    Warren G almost 7 years
    Thanks for taking the time Igor, I'm still not exactly sure why - but I have managed to figure out that that custom /login page that was generated by the membership plugin years ago is part of the problem (it has always worked fine, but the new updates seem to have conflicted somehow) i.e. if I disable the custom login page and use classic WP login page it works. So now I need to figure out how to get the same functionality of a custom login page that doesn't clash with new versions of everything (seems I might be hunting for new membership plugin) - thanks again for your suggestions
  • Igor Araújo
    Igor Araújo almost 7 years
    Warren, in this case you could find other plugin with the same funcionality. Or you can try to fix this one: updating the plugin version or reinstalling the same. You also can verify in error.log if there are any errors about (if it is not, activate wp_debug in wp-config.php.
  • Warren G
    Warren G almost 7 years
    Thanks Igor, you are quite right. After talking with the plugin maker, we found a solution (which may help others who also have this issue due to any plugin they use): It simply required a line of code to go in one of the plugin's main PHP files, that fixed it as a 'buffer issue' (the line referenced Ajax with a buffer correction specification) - I wont post the code since it is plugin specific, but others should note Buffer issues as a potential cause if they get this kind of problem - and put a simple code fix in the right place.
  • orghu
    orghu over 6 years
    With the "plugins.old" trick (renaming the plugins folder) I succeeded to enter the admin area (/wp-admin), Luckily this way they all became inactive, easier to debug. So I could find/debug the plugin that caused the trouble. Thank you!
  • thmspl
    thmspl over 4 years
    Could you tell a little bit more how you solved the problem by using the repair feature? Explain more about the repair feature you have used.