• Hi. In my theme, the category links show up as:

    http://domain.com/wp/category/mycat

    For backward compatibility of URLs, I would like to remove the bold word in that URL (“/category”) because wordpress in fact works if I remove that. Just the name of the category (“mycat” in my example) is fine to bring up the category archive without any problem.

    Thanks for any tips!

Viewing 10 replies - 1 through 10 (of 10 total)
  • use a rewrite

    Thread Starter erick_paper

    (@erick_paper)

    I think it’s not an issue of doing a rewrite, because the theme itself writes the URLs. I want to change how the category URL is linked from within the theme while calling wp_list_categories.

    So the “/category” is autmatically added by WP!

    I checked the options for this function:
    http://codex.wordpress.org/Template_Tags/wp_list_categories

    But there seems to be none that allows me to personalize the word used for “category”.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    You can change the word to anything you like on the Options->Permalink page, but you cannot remove it. The identifier is needed to signal that you are asking for a category.

    As for why it works without it, let me guess: Your Custom Permalink string starts with /%category% , right? If it didn’t, then leaving it out would not work.

    Removing it entirely would require a large rewrite of the internal rewrite and query system. Using category in the custom permalinks is a bit of a hack anyway, since there is not a one-to-one correspondence between categories and posts; posts can have more than one category.

    Thread Starter erick_paper

    (@erick_paper)

    Thanks for a very informative post!

    I found the “category base” works for me.

    I have a site that automatically lists the categories prefixed with “domain-name/category/directory-name”.

    If you create a navigation menu and simply hard-code “domain-name/directory-name”, I’ve discovered that it works just the same; The hard-coded urls also get indexed like every other page on your website or blog.

    – I’ve used this technique on my sites that I want to ensure the url and directory can easily be memorized.

    However, in most cases, if you dont have a SEO keyword in your domain name, I recommend using the “category” structure and replace that with an industry keyword.

    Using “/.” (without quotes) as the category base should work

    Hmm… it did work, but not anymore.
    Seems not to work all the time, anyone know why?

    Use the top level categories plugin, if you want to remove the prefix altogether.

    CodePoet

    (@design_dolphin)

    Alfa code

    Important! Not for live website use unless you know what you are doing. For development use until testing has been completed and reviewed by a community of peers. If implemented (incorrectly) it can cause site errors. Use at your own risk.

    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L]
       RewriteRule category_base/(.*) http://yourdomain.com/$1 [R=301,NC,L]
      	</IfModule>

    Ran into the similar problem of wanting the category base word out of the url.

    Am testing the code above in the latest stable version of 2.7. ‘category_base’ is the category base name from the permalinks settings menu.

    Haven’t run into any problems with it, but haven’t tested it extensively enough to say without a shadow of a doubt it will work all the time and safely. So far the urls of the site that I have tested index.php, categories, single pages as well as comments appear to work.

    In the permalink settings in the settings menu the ‘custom structure’ is selected and set to:

    /%category%/%postname%.html

    I will put “.” (dot) as a category base, and it’s will nice shown now as /./category/. But, is there any chance to remove this dot? Without .htaccess. May be there are some hidden features in WP?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to remove “/category” from the category URL?’ is closed to new replies.