1

I have copied a wordpress instance from production to my local. After getting the public side of the site up - public homepage, pages, and blog posts -, I cannot access /wp-admin/ because that url always redirects to the / homepage. I have tried:

  • Updating the siteurl and home to "https://tk.local" (homepage and posts work fine)
  • Implementing a local self-signed ssl cert (in case it was an https problem.)
  • Switched to 2019 theme (theme works, but problem still persists)
  • Setting debug constants in wp-config.php
  • Removing debug constants in wp-config.php
  • Moved the plugins directory aside, replaced with /plugins containing only index.php

Here is a curl of wp-admin:

curl -Ik https://tk.local/wp-admin/
HTTP/1.1 301 Moved Permanently
Server: nginx/1.16.0
Date: Wed, 24 Jul 2019 17:27:39 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.40
X-Redirect-By: WordPress
Location: https://tk.local/
Last-Modified: Wed, 24 Jul 2019 17:27:39 GMT
Expires: Wed, 24 Jul 2019 18:27:39 GMT
Pragma: public
Cache-Control: max-age=3600, public
ETag: "d41d8cd98f00b204e9800998ecf8427e"
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-uri: /wp-admin/

Obviously on the production copy the wp-admin url works. Throughout it all, it 301 redirects from https://tk.local/wp-admin to https://tk.local/ How can I prevent it from redirecting?

  • 1
    Have you disabled all your plugins on tk.local and switched to a default theme? What does the .htaccess file look like on tk.local? When you say you tried Updating the siteurl and home to "tk.local", did you set them to tk.local or https://tk.local? – Pat J Jul 29 at 18:40
  • 1
    @PatJ Yes. I moved the plugins directory away and replaced it with a clean install version that just contains index.php, still redirects. No .htaccess, I am using nginx without any redirections that list wp-admin. Yes, the siteurl and home setting are set to https. – Kzqai Jul 29 at 20:01
  • 2
    Does there happen to be an .htaccess file within the wp-admin folder? Have you tried starting with a fresh copy of WordPress and copying in the wp-content folder from the production site? – socki03 Jul 29 at 20:35
  • @socki03 Your idea to replace the outer source code make it clear that since the source was identical to wordpress 5, it had to be my nginx config. I wouldn't have thought of just wiping all the non wp-content source code temporarily, but it was helpful. If you want to make it an answer, I'd look at giving that the bounty. – Kzqai Jul 29 at 23:15
3

In my case, it ended up being some kind of adverse interaction in the nginx wordpress config that I had. Something about not passing along the naked arguments:

        location / {
original line:               try_files $uri @php;
new line:        try_files $uri $uri/ /index.php?$args;
        }

And the associated upstream was wrong. Used the config suggested here: https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/ For a simpler wordpress nginx config and that solved it.

1

Please try going into the local database and looking in the options table for the home and site url. Make sure these values correctly reference the local site URL.

Alternatively, in your local wp-config.php file you could try defining the home and site url constants like this:

define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );
1
+50
  • Look into .htaccess, there might be set some specific urls/directories, which you might need to remove/change, like:

    RewriteBase /subdir/

  • Also, in phpmyadmin, check wp-options first and second rows, there should be needed similarly modified site-url .

  • If MultiSite, then change that in wp-config too.

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.