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
I think you have installed any redirect plugin and set redirection otherwise 301 redirect.
Please update the permalinks settings. Hope your issue will be solved.
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.
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.
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:
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.
Clear your Browser Cache & Caching plugins
Note: some security plugins also use caching e.g. Securi, so check those too.
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.