0

I have a WordPress website on a Digital Ocean VPS which I've come back to and tried to log into the admin panel through the 'wp-admin' link. For some reason I can't access it now. The website gets redirected to 'http://%24domain/wp-admin/' which is a broken link.

Here are the current things that I have tried but nothing has worked so far:

  • Renaming the plugins directory so they appear deactivated

  • Adding the following two lines to wp-config.php: define('WP_SITEURL', 'http://example.com'); define('WP_HOME', 'http://example.com');

  • Keeping the theme/plugin files but re-uploading the core WordPress files

  • Changing some options values (but adding a custom script which requires wp-load.php): update_option('siteurl', 'http://example.com' ); update_option('home', 'http://example.com' );

  • Deleting the .htaccess in the root directory

None of these have worked and I have no idea why the admin panel can't be accessed and redirects to that domain.

Can someone help me get the admin panel working again? Any help is much appreciated!

1

first of all you shouldnt delete .htaccess file. create another one in the root directory and add following lines to it:

# 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

then go to wp-config.php and add these lines:

define( 'WP_HOME', 'http://youresite.com' );
define( 'WP_SITEURL', 'http://youresite.com' );

now go to wp-admin and hopefully youre redirect problem will be fixed.
dont forget to remove last code from wp-config after fixing youre issue.

0

The other answer is a good start. Although I prefer to change the two URLs in the wp-options table, which is read first on all page loads (and is indicated as the preferred method in the Codex).

See this entry in the Codex https://codex.wordpress.org/Changing_The_Site_URL where it says:

This is not necessarily the best fix, it's just hardcoding the values into the site itself. You won't be able to edit them on the General settings page anymore when using this method [setting values in wp-config.php, emphasis added].

So, although changing the values in wp-config.php will work (and is often stated as an 'answer'), I think that the more correct way is to set the proper URLs in the wp-options table.

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.