Wordpress new page redirects to old 404 page

2019-08-17 05:36发布

I have this strange problem in Wordpress. If I create a page such as Lead with a slug lead and therefore url http://example.com/lead. If I enter the url http://example.com/lead into the browser it ends up being redirected to http://example.com/learning/program/lead

I have tried to disable wordpress automatic redirection feature with;

remove_filter('template_redirect', 'redirect_canonical');

But that does not seem to work. Even when both pages don't exist I end up with; http://example.com/learning/program/lead

4条回答
一夜七次
2楼-- · 2019-08-17 05:50

I think you have installed any redirect plugin and set redirection otherwise 301 redirect.

查看更多
一纸荒年 Trace。
3楼-- · 2019-08-17 05:53

I suspect this is happening because the WP database still has information on the old lead slug that you have deleted.

When you change a slug, the old permalinks are still stored in the database which can cause issues if you want to reuse that name.

  1. Check your Trash:
    Make sure that the post/page/category/whatever has been deleted and is not sitting in your trash - if a post is still in trash, WP still treats the slug as in use.

    After it has been deleted permanently from trash:

  2. Flush your Rewrite Cache:
    There are Three Ways to Flush the Rewrite Cache in WordPress:

    • re-save your permalinks in the Admin
    • call flush_rewrite_rules(); in your functions.php (only add it temporarily - you don't want it to run all the time).
    • delete the cache from the database: Run the following query in the database:
      SELECT * FROM wp_options WHERE option_name = 'rewrite_rules'
      You should only get 1 result - edit it to remove the option_value. See Three Ways... for more info.
       
  3. Clear your Browser Cache & Caching plugins
    Note: some security plugins also use caching e.g. Securi, so check those too.
     

  4. Delete old WP permalinks
    If its still not working, run this query in your database to clear all the old slugs from the postmeta table:
    DELETE FROM wp_postmeta WHERE meta_key = '_wp_old_slug';

    Ref 'Remove Old Permalinks?'
     
    Note: Back up your database before you make any changes in there directly - any mistakes could break your site.

查看更多
迷人小祖宗
4楼-- · 2019-08-17 06:15

You should try with another browser, 301 is a permanent redirection and it can be difficult to get rid of it. In firefox you have to clear the network cache, in the networking settings of firefox.

查看更多
在下西门庆
5楼-- · 2019-08-17 06:16

Please update the permalinks settings. Hope your issue will be solved.

查看更多
登录 后发表回答