0

Whenever I post a new post or page, the website serves a 301 redirect to the homepage. All existing posts are working correctly (not redirecting).

What I've tried:
- Checked console and confirm APACHE is serving 301
- Tried to re-save permalinks from Wordpress
- Checked .htaccess for anything out of the ordinary

The problem was cause by previous developers and I'm unable to trace their work.

Any help is appreciated, thanks.

  • 1
    are the permalinks for new posts and pages different in any way? – inarilo Dec 26 '17 at 5:45
  • @inarilo No, just using post name for the permalinks. – Boris Panov Dec 26 '17 at 10:00
0

Out of curiosity, does the Post Preview page redirect as well?

If it don't redirect, then it sounds like a cache problem.

If it does redirect, there are more things to try.

NB: First back-up your site (always a good idea before debugging anything.) As you may not know what the developer edited, back up all files and the database as well.

If you have any caching / cache plugins, clear all cache files and then deactivate cache plugins.

Check status of the redirect.

If it's still there, then try re-install WordPress. Login and go to Dashboard --> Updates. Click the Re-install Now button.

Check status of the redirect.

If still there, then you might have to consider deactivating plugins (one at a time) and check which could be causing the problem. I would normally start with any SEO plugins and Cache plugins.

If still nothing, then deactivate the rest, one by one, and check the redirect after each.

If no change, then it seems to be an issue with the Theme.

You can try change the theme to test. ** Please note, sometimes changing the theme can reorganize the widgets and cause some widgets not to show. So if you have a lot of special widget configuration, then you might want to hold off. Or if you are confident you can restore the site from back up, then you can give it a shot.

0

There are a number of possible culprits for this issue, below are recommended courses of action to debug and resolve:

Caching

  1. first you'll want to make sure it's not local caching or we server caching. If your hosting provider or dns service provides varnish caching or the like (pantheon, wpengine both have caching in place, as do cloudflare and dyn), reset it after saving your new content. Then perform a hard refresh on your browser when visiting the url of any new content in an incognito / private window.

Test Locally

  1. Next, if it still occurs after clearing caches and a hard refresh, clone the site down to a local development sandbox (having done a find and replace for the domain in both wp-config.php and the database). Do you exhibit the same redirect issue?
  2. If so, it may be an error in .htaccess- try backing up the existing .htaccess and replacing with a fresh copy from a WordPress installer/download.
  3. If after changing the .htaccess file, you continue to exhibit the issue locally, it could be a custom redirect in the site's theme or plugin codebase. You could search for a php header() function call in the wp-content folder similar to:

    <?php header("HTTP/1.1 301 Moved Permanently");  header("Location: http://www.example.com");  ?>

Or a legacy html metatag redirect similar to:

<meta http-equiv="refresh" content="0;url=http://www.example.com/new-page.html">
  1. if you still exhibit the issue ( locally) after changing the .htaccess file and checking for a coded redirect rule, it could be a plugin setting in the database. Check for any plug-ins that might have redirect functionality and disable them one at a time to see if they are the cause.

Server Config

  1. If the redirect still occurs, having tested locally with no issues, it's definitely server side. Double check whether the live front end of the site actually is serving Wordpress from the database defined in wp-config.php you may accidentally be redirected to a dev or staging copy of the site on the live web server, adding content to it, but then trying to visit the page on a different instance in the front end.

  2. If you still exhibit the issue but only on the server, check the vhost configuration file (if you have full Admin / root access to a cost)

  3. If your WordPress site is actually a subfolder/subsection of the larger website, check for any htaccess rules at the parent level folder that may be conflicting.

Otherwise, you may need to delve further into the code and database/site config if the none of the above identify the culprit.

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.