1

I installed WordPress locally and created a theme, which worked fine. Now, as I wanted to deploy the site to a webserver via FTP, I got stuck by an 301 Redirect loop which makes it impossible to reach the site (except for the backend login).

I moved WordPress into a subdirectory because I don't want to override the current site. The following steps didn't work:

  • Changing siteurl and home from the wp_options table (tried both www and non-www)
  • Editing the .htaccess so the RewriteBase is correct. After this didn't work, I deleted it, still no success
  • Search and replace the database for entries which might have the old url (using this script)
  • Deleting the .htaccess from the root directory (htdocs)
  • Renaming the subdirectory and changing all paths again
  • Overwriting the siteurl and home via wp-config.php

None of this worked. I know that the host forces to redirect to www, but no matter which kind of url type I enter, still redirecting. Any ideas?

PS: If I upload a single index.html file to this directory, it works fine...

2
  • Have you tried clearing your browser cache? Commented Jan 15, 2015 at 11:53
  • Yes I did. Didn't help.
    – Andrew
    Commented Jan 15, 2015 at 12:15

3 Answers 3

2

As mentioned in my comment, ensure you test the following in a "clean" browser:

  1. Set siteurl & home to http://www.example.com/wordpress-subdirectory
  2. Set permalink_structure to nothing
  3. Set active_plugins to nothing
  4. Ensure there are no WP_SITEURL or WP_HOME constants defined in your wp-config.php
  5. Remove all rewrite rules to do with WordPress from your .htaccess

Not of all these steps are necessarily required, but I'm trying to cover all bases here.

Attempt to log in. If you hit a white screen of death, it's most likely that your active theme is calling plugin-dependent functions. Change stylesheet and template in wp_options to twentyfifteen (or any default theme, and ensure it exists in your themes directory).

Test the frontend. All good? Go and activate each plugin again, one by one, testing the frontend each time.

Hit the problem again? Clear browser cache and reset active_plugins, then install & activate Deploy Helper

Head over to Tools > Deploy Helper.

In the "Fix paths and URLs" section, set From to http://localhost (or whatever you were using during development) and To to http://www.example.com/wordpress-subdirectory. Leave server paths as they are.

Run Fix.

Activate the troublemaking plugin again and all should be well.

3
  • I figured out what the problem was (see me answer). Thanks for your help.
    – Andrew
    Commented Jan 15, 2015 at 13:06
  • 1
    You are a lifesaver. I spent hours trying to figure out what caused my infinite redirect problem, looking at every post and instruction video, and you are the only one who suggested clearing the permalink_structure, which actually solved my problem.
    – Royar
    Commented Nov 22, 2019 at 20:04
  • I experienced the same symptoms after copying a website to a staging domain to complete some work, including enforcing SSL. In my case the redirect loop was caused by a misconfiguration on Cloudflare where SSL was set to Flexible instead of Full. Commented Jun 10, 2021 at 11:48
0

I found the issue: it is a strange server configuration. The port mapping is a bit odd, since the port 80 is mapped to a five-digit port on the other side. That's why WordPress redirected into a loop.

To fix this kind of issue enter the HTTP port number into your WordPress settings:

http://your-domain.com:80/directory or https://your-domain.com:443/directory

Thanks TheDeadMedic for your help!

0

Thanks to wpbeginner:

Go to Settings » General, change your WordPress and Site Address. If you have your address with www prefix, then change it to non-www URL, and if you have it with non-www URL then add the www prefix.

Of course, this can be edited directly in the WP_SITEURL and WP_HOME entries in the database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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