• kulandai

    (@kulandai)


    Hi,

    I am using a custom theme. I am having Permalink Custom Structure:

    /%category%/%postname%/

    This permalink structure creates a page as phppot.com/php/ actually this should go to page not found.

    Here ‘php’ is category-name. So, a valid category page is

    /category/php/

    I checked with a temporary fresh WordPress install with 2024 theme. Then used the same permalink and the same behavior happens.

    Question: Why does WordPress create a page like this phppot.com/[category-name]/ – This URL gets mapped to archive.php

    The problem:
    phppot.com/[category-name]/ and phppot.com/category/[category-name]/ are duplicate pages.
    There are no pagination for this odd url.

    I checked a popular blog and see that they have redirected domain/[category-name]/ to domain/category/[category-name]/

    Kindly let me know why this URL phppot.com/[category-name]/ is working. Actually it should give page not found.

    Solution: Shall I do a .htaccess based redirect for all my categories one by one? or is there a better solution to fix this?

    Thanks for your help in advance.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You’re right, example.com/category/ and example.com/[category-name]/ should both return nothing found 404 pages. If that is not your experience, your theme or plugin has altered rewrite rules to alter default behavior.

    To determine which module is the cause, switch to a default theme and deactivate all plugins. Visit the permalinks settings screen to regenerate rewrite rules. No need to save anything, loading the page is enough. You should now see normal, expected behavior.

    Restore your normal theme and plugins, one at a time. Revisit permalink settings and test after each activation. When undesirable behavior returns, the last activated module is the cause. Take up the issue through its dedicated support channel.

    You’re right, example.com/category/ and example.com/[category-name]/ should both return nothing found 404 pages. If that is not your experience, your theme or plugin has altered rewrite rules to alter default behavior.

    I think OP’s issue is slightly different from what you’re saying, and it’s not theme/plugin related: it’s (one of many) WordPress permalink quirks.

    OP’s issue is specifically for the case when the permalink structure is set to /%category%/%postname%/

    Post permalink becomes /[category-name]/[post-name]/ as expected.

    Category permalink remains /category/[category-name]/ as respected.

    But, there’s a duplicate category permalink at /[category-name]/ — which is unexpected and undesired.

    I can reproduce this on a fresh WordPress 6.5 installation with just the default theme and no plugin at all. And this ONLY happens with the permalink structure set as /%category%/%postname%/

    Thread Starter kulandai

    (@kulandai)

    @gappiah yes you are right. @bcworkz This happens with a fresh WP 6.5 and just the default theme too.

    The essence is, this odd URL gets created only when the permalink structure is /%category%/%postname%/

    So I assumed this cannot be an intended behavior. Then, should it be reported as an issue?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Permalink Custom Structure creates an odd url’ is closed to new replies.