Support » Plugins and Hacks » which file do i need to hack for mod_rewrite?

  • i want to do this: site.com/blog/food/
    instead of: site.com/blog/category/food/
    i tried editing .htaccess:
    RewriteRule ^?(.*) /blog/index.php?category_name=$1 [QSA]
    but that is only halfway, since it still needs to be hacked in WP.
    Does anybody know which WP file i need to hack?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Ryan Boren

    (@ryan)

    WordPress Dev

    For 1.0.2 and earlier, change wp-admin/options-permalink.php. For nightlies, change the rewrite_rules() function in wp-includes/functions.php.
    Make sure you move that rewrite rule to the end of the list in .htaccess. It is greedy and will gobble up everything. That is why we have /category/(.*), /author/(.*), /feed/(.*), /comments/feed/(.*), and so forth. If we tried to dangle them all off the root, they would clash horribly and only the first RewriteRule would work.

    Ack, rboren beat me.

    hrm, im unable to make this happen.
    i tried this simple test on line 145 of options-permalink.php.
    $catmatch = $front . 'TESTegory/';
    I then reapplied the permalink structure thru wp-admin
    it gave me a new .htaccess, which i uploaded.
    it still shows /category/food.

    Moderator Ryan Boren

    (@ryan)

    WordPress Dev

    Per the instructions of post 3298 I did the following:
    File: /wp-admin/options-permalink.php
    Find line 146: $catmatch = $front . 'category/';
    Replace: $catmatch = $front;
    File: /wp-includes/template-functions.php
    Find line 1362: $link = $siteurl . $front . 'category/' . $category_nicename . '/';
    Replace: $link = $siteurl . $front . $category_nicename . '/';
    That all worked perfect.
    Now I am having trouble with the mod_rewrite rule. I tried several different ones. Including the ones with the +. I got a lot of Server 500 errors and a lot of server ‘stalls’. I even tried the mod_rewrite RewriteRule Generator which didnt help much either.
    Any idea how to format the RewriteRule?

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.