WordPress.org

Forums

Old Slugs Removal (8 posts)

  1. meraj.khattak
    Member
    Posted 1 year ago #

    Hello,

    I renamed slugs of my pages and it is redirecting to old slug.

    old url: /my-old-page-name/
    new url: /my-new-page-name/

    So now my page was accessible at both URLs. Now if I don't want this old URL, I will remove it from 'wp_postmeta' where meta_key = '_wp_old_slug'.

    I have done this but I am still able to access my old url. How could I completely remove this?

    Thanks.

  2. Krishna
    Volunteer Moderator
    Posted 1 year ago #

    You need to delete the old slugs and create new ones. When you rename, the old slogs remain and new ones are created.

  3. meraj.khattak
    Member
    Posted 1 year ago #

    I have deleted the all the old slugs. New slugs are in place. But still it is redirecting to the these old URLS.

    Is there any other place where it could be checked for redirection?

  4. frizax
    Member
    Posted 1 year ago #

    In wordpress when you change slug of a page or post, it keeps old slug in database. And there is a function which auto redirect old slug to the new one.

    If you don't want redirection on old slug you have to remove it from the database. These can be removed by using following mysql query (link):

    DELETE FROM wp_postmeta WHERE meta_key = '_wp_old_slug';
  5. meraj.khattak
    Member
    Posted 1 year ago #

    Thanks Frizax. I have removed old URLs. But it is still accessible via old URLs and it redirects it to new one.

    I have confirmed and don't have any rules defined in .htaccess for this.

  6. Krishna
    Volunteer Moderator
    Posted 1 year ago #

    Clear caches and cookies and try again.

  7. meraj.khattak
    Member
    Posted 1 year ago #

    Clearing cache and cooking and then trying again didn't help. Will look into this more and update.

  8. meraj.khattak
    Member
    Posted 1 year ago #

    Solved. I noted that an .htaccess outside my root folder of WordPress was causing this issue.

    What is strange is that the directory in which .htaccess was causing was not even in my DocumentRoot. The structure was as the following:

    • /home/mrk/www/ - This was my DocumentRoot in Apache and WP root as well.
    • /home/mrk/.htaccess - This was causing issue. I don't know how that was possible when it was not even defined as DocumentRoot for Apache? Probably as parent directory of DocumentRoot?

    Anyway, thanks for all your kind help.

Topic Closed

This topic has been closed to new replies.

About this Topic