Forums

[resolved] how to hide category in url? (mod_rewrite) (5 posts)

  1. afex
    Member
    Posted 5 years ago #

    hi all. i'm setting up wordpress and i'd like to do something like this:

    lets say my website is "http://www.a.com" and i have two categories "b" and "c"

    currently they show up like "http://www.a.com/category/b/" and "http://www.a.com/category/c/"

    but i would like them to show up like "http://www.a.com/b/" and "http://www.a.com/c/"

    what rewriterules should i add to my .htaccess to have this happen? (i'm good with regular expressions but i'm unfamiliar with mod_rewrite and how to script it. thanks!)

  2. afex
    Member
    Posted 5 years ago #

    k i figured this out, and it doesn't involve mod_rewrite.

    in /wp-includes/classes.php find this line (1079)

    $this->category_structure = $this->front . 'category/';

    and replace it with

    $this->category_structure = $this->front . '';

    and thats it! there may be some other issues with this i haven't found, but it does change the links generated to categories by wordpress, and following those links brings up the correct archive page.

  3. alang
    Member
    Posted 5 years ago #

    I tried this mod but whenever I clicked on post url, I'll get 404 error

  4. Chris_K
    Member
    Posted 5 years ago #

    Note that if you try that mod things will get interesting if you have a WP Page name the same as a Category name.

  5. afex
    Member
    Posted 5 years ago #

    thats true handysolo.

    the way my site is structured, there are only two main "sections" which are the "b" and "c", and i dont use the pages feature of wordpress. (yet)

Topic Closed

This topic has been closed to new replies.

About this Topic