WordPress.org

Ready to get started?Download WordPress

Forums

Removing 'Category Base' From Permalinks (24 posts)

  1. Charbax
    Member
    Posted 6 years ago #

    Using the latest version of the Top Level Categories plugin from http://fortes.com/2007/06/20/top-level-categories-plugin-10/ this nearly seems to work!

    Most of the blog works as you can see on my install of it at http://techvideoblog.com other than navigating to 'Previous Entries' or using the wp-pagenavi page navigation plugin that I put in the header.

    Basically these types of URL mess up the navigation:
    http://techvideoblog.com/cebit/page/4/
    http://techvideoblog.com/pmp/page/4/

    The blog doesn't seem to know it is on the 4th page in terms of displaying the 'Previous Entries' 'Next Entries' and displaying the wp-pagenavi links correctly. This seems to be the only problem with the Top Level Categories 1.0 plugin.

    This part of the blog works:
    http://techvideoblog.com/cebit/?year=2006&paged=2
    (as you can see 'Previous Entries' and 'Next Entries' works because it is in the ?year=2006& but that type of URL is only done manually.

    This topic has been covered in http://wordpress.org/extend/ideas/topic.php?id=359 but still doesn't seem to be resolved. I tried the suggestion at http://bloggerholic.com/wordpress/how-to-remove-category-base-from-permalinks-45.htm and it doesn't seem to work on my installation of WordPress 2.2.

  2. Charbax
    Member
    Posted 6 years ago #

    I think the solution to removing Category Base would be to have wordpress use following type of paging links:

    /?paged=2

    instead of

    /page/2/

    So the thing I would think would be the solution, is if you can set a normal folder based permalinks for everything else, including posts, categories, but just have /?paged=2 to be used instead of /page/2/

    Is it something that needs to be tweaked in rewrite.php? Could someone help me to get this workaround working?

    You can see an example on my blog:
    http://techvideoblog.com/cebit/?paged=6 works
    http://techvideoblog.com/cebit/page/6/ doesn't work (in terms of "Previous Page", "Next Page" and PageNavi don't know it is on the 6th page.)

    I think if wordpress could be tweaked to use /?paged=6 instead of /page/6/ then all the people asking for it in http://wordpress.org/extend/ideas/topic.php?id=359 would also be able to use WordPress now without having to use a category base folder name.

  3. moshu
    Member
    Posted 6 years ago #

    Removing the category base would result that WP cannot make a difference between a Page
    example.com/page-slug
    and a category archive
    example.com/category-slug
    THAT's why it is there. Usually all the "smart" workarounds to remove it end up in broken blogs.
    You were warned...

  4. Charbax
    Member
    Posted 6 years ago #

    Yes but I never think I will name a page the same as the category. So for me it wouldn't be a problem.

    This is how my blog works for now with http://fortes.com/2007/06/20/top-level-categories-plugin-10/ installed and %category%/%postname%/ permalink:

    http://techvideoblog.com/page/4/ - works fine
    http://techvideoblog.com/%category%/%postname%/ - works fine for blog post permalinks.

    Problematic:
    http://techvideoblog.com/pmp/page/4/ - paging within categories, wordpress doesn't know what page it is on, so "previous page", "next page" and pagenavi plugin links are incorrect, it always thinks it is on page1 of the category.
    http://techvideoblog.com/cebit/2006/ - doesn't work

    If I manually enter these kind of URLs:
    http://techvideoblog.com/cebit/?year=2006 - works fine, and WordPress links to this for paging:
    http://techvideoblog.com/cebit/?year=2006&paged=4 - works fine.

    http://techvideoblog.com/pmp/?paged=4 - works fine including "next page", "previous page" and pagenavi.

    So the only thing needed I think for this to work, would be to change something in WordPress so it uses ?paged=4 instead of /page/4/ while keeping all the rest of the clean permalink structure and using the TopLevel Category plugin.

    Another solution I've seen people use is to use following permalink structure: %category%/%postname%.html

  5. moshu
    Member
    Posted 6 years ago #

    Quote:

    Usually all the "smart" workarounds to remove it end up in broken blogs.
    You were warned...

  6. Charbax
    Member
    Posted 6 years ago #

    I'm looking at the rewrite.php file.

    All that is needed for this to work, is a workaround to use ?paged=2 type of links instead of /page/2/.

    Usually ?paged=2 links are only used for when the rest of the permalink structure is using ?p=105 kind of page permalinks.

    I wouldn't mind using the uglier ?paged=2 URLs for paging as long as I can have super clean category permalinks that doesn't require to use a category base.

  7. Os..
    Member
    Posted 6 years ago #

    You may try this if you can read german (kills the /category/ in url):
    http://www.einfach-persoenlich.de/2005-08-16/wp-wordpress-wordpress-url-design-ohne-category-ballast.html

  8. WWDay3
    Member
    Posted 5 years ago #

    Moshu said:

    "Removing the category base would result that WP cannot make a difference between a Page
    example.com/page-slug
    and a category archive
    example.com/category-slug
    THAT's why it is there. Usually all the "smart" workarounds to remove it end up in broken blogs.
    You were warned..."

    That's a copout. Any good entity-driven database would prevent duplicate entities from being created (and the "resolved" WP slug scheme resembles an entity-driven database, even if it's not entirely so under the covers). It is something that *should* be fixed. Page and post and any other slugs should not be allowed to be duplicated.

  9. scribu
    Member
    Posted 5 years ago #

    If you have WordPress 2.5 you can just set the category base to "/." (without the quotes) and it will work fine without any additional plugin.

  10. Zhu8
    Member
    Posted 5 years ago #

    If you have WordPress 2.5 you can just set the category base to "/." (without the quotes) and it will work fine without any additional plugin.

    Oh? just so easy...

  11. scribu
    Member
    Posted 5 years ago #

    Try it for yourself if you don't believe me. :)

  12. WWDay3
    Member
    Posted 5 years ago #

    It works great. I've used it in a couple new blogs with nary an issue.

    Not sure if it would use it that way for tags. Might get some conflicts there.

    If you use it I would suggest naming your categories very carefully so you won't conflict with a post slug in the future (probably not an issue with most blogs I've visited).

  13. flick
    Member
    Posted 5 years ago #

    Just to clarify, in the permalink editing box of a post, you would put
    /.the-slug to avoid the category base? :)

  14. onsitus
    Member
    Posted 5 years ago #

    Hi,

    I tried and tested (for what I can) right now this hack proposed by Scribu using as Custom Structure:
    /%category%/%postname%/
    and as Category Base:
    /.

    First problem I had:
    I had a folder named the same as a category for this reason I encountered the first error. Solution: changed the name of the folder. Easy enough!

    Second problem with the archive:
    In the home page it would go fine passing from one page to another, instead once inside the categories, it would not find page 2 (as ex). Solution: changing the Custom Structure for /%category%/%postname%.html

    I am using WordPress 2.5.1 and tested it on IE7, Firefox 2, Safari 3 (mac and windows) and Opera 9.

    With IE6 I get for the categories an url type http://www.mysite.it/./category
    still working fine though. Same thing in the sitemap.xml (created automaticaly with a plugin). I edited it by hand but obviously each time I add a new post, the sitemap xml is recreated and it goes back as it was. I don't know if it could create problem for the search engine. I have to inform me on this one!

    I will carry on study this thing.

    Regards,

    Gaelle

    PS: sorry for my english, it is not at its best (o:

  15. WWDay3
    Member
    Posted 5 years ago #

    You're saying in IE6 it put the category base '/.' in the url? Weird.

    I have 3 blogs running now using this technique, and they seem fine.I will say, however, that when it comes to sub-categories, all bets are off...

  16. scribu
    Member
    Posted 5 years ago #

    With IE6 I get for the categories an url type http://www.mysite.it/./category

    That really is weird. I thought that the redirections are done solely through mod-rewrite, thus being browser independent. From what you say, I guess that's not the case.

    You could try this Redirection Plugin.

  17. microkid
    Member
    Posted 5 years ago #

    Using "/." as your category base will result in links like this all over your blog:

    http://www.example.com/./news/

    Look at your source if you don't believe me.

    Most browsers are smart enough to recognize how this, as a server path, is the same as leaving the "/." out. So it's the browser who "rewrites" the link to

    http://www.example.com/news/

    IE6 appearently doesn't. But you can see how this is quite a dirty hack.

    Moshu is right, there is no good solution for this, and this will result in problems.

    Which is sad, because if it were possible, the link structure of your blog would be logically hierarchical, which would help SEO. If you're using /%category%/%postname%/ that is.

  18. scribu
    Member
    Posted 5 years ago #

    IE6 appearently doesn't. But you can see how this is quite a dirty hack.

    Well, to clean it up you can just set a 301 redirect through .htaccess or with the plugin mentioned above so that it works in all browsers, with no SEO penalty.

  19. WWDay3
    Member
    Posted 5 years ago #

    Well, to clean it up you can just set a 301 redirect through .htaccess

    Mind giving those of us who always mess up .htaccess an example version of the code?

  20. scribu
    Member
    Posted 5 years ago #

    It would be something like this (it works for even more than one dot and also eliminates multiple slashes):

    RewriteRule /\.*/(.*) /$1 [R=301]

    But it seems to get ignored by WordPress, no matter where I put it in the .htaccess file. Using the Redirection Plugin works, though.

  21. scribu
    Member
    Posted 5 years ago #

    Usually all the "smart" workarounds to remove it end up in broken blogs.
    You were warned...

    I'm also beginning to think that moshu is right. I just found out this little detail:

    http://example.com/anything-at-all!/category_slug

    displays exactly like

    http://example.com/category_slug

    This means anything can be put between the domain url and the category_slug and it won't cause a 404. Help!

    PS: I tried the default category base and a custom one and it didn't fix it.

  22. onsitus
    Member
    Posted 5 years ago #

    Good evening,

    I read everything and although you did give me doubt about it, I have been keeping a close eye at the result on Google for the past weeks. The site has been online for 3 weeks now and is climbing nicely to first page without using redirection tools or modifying the .htaccess.
    About the site itself, I have not encountered any errors while or after posting.

    Boh...I don't really know what to think!

    About this:
    http://example.com/anything-at-all!/category_slug
    Why would someone type that kind of url except someone like us???
    Then again I tried it on another site which as not the urls modified and it does the same defect for the articles tipe mySite/myPost is the same as mySite/anything-at-all!/myPost and won't give error 404.

  23. scribu
    Member
    Posted 5 years ago #

    Well, if someone wanted to discredit a site it could link to an article and add "porn" or "idiot" in the url and that would get indexed by search engines, thus becoming a major embarasment for the site owner.

  24. jonez
    Member
    Posted 5 years ago #

    This requirement for a category base is pretty much a religious tenant at WordPress... and I've never understood the ferocity.

    I've been using the /. "hack" for about two years, since I love simple, elegant URLs. I'd be happy to leave my site's URL to await 'major embarrassment'. :)

    -Jeff

Topic Closed

This topic has been closed to new replies.

About this Topic