Support » Fixing WordPress » Rewrites Rules Does not work with WP 2.0

  • Resolved argiope



    I just upgraded to WP2.0. 2 out of 3 blogs of mine have no problems but I have a problem with the 3rd.

    I’m using permalink structure as /%year%/%monthnum%/%day%/%postname%/
    I have no problems with that. It’s working good.

    However I use some shortcut urls inside my posts for other posts of mine.

    So before WP2.0 I was using an extra mod_rewrite rule
    in my htaccess as:

    RewriteRule ^(shortcut)/(.+)?/?$ /index.php?name=$2&page=$3 [QSA,L]

    simply I catch whatever url starts with the keyword (shortcut) and match it to index.php with the name=%postname%

    I realized that WP2.0 has a non-verbose structure as
    RewriteRule . /index.php , really cool job but it effects
    my shortcuts.

    So I changed use_verbose_rules to true in WP_Rewrite and recreated the permalink structure but it didn’t help.

    Currently my site is down because of this problem.

    How can I make custom permalinks like my shortcuts but still continue using long permalik structure?

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Instead of using the verbose rules, try putting something like this in a file named functions.php in your theme folder, and take advantage of WP 2.0’s internal rewrite system:
    function shortcut_filter($rules) {
    $rules['(shortcut)/(.+)?/?$'] = 'index.php?name=$2&page=$3';
    return $rules;
    add_filter('rewrite_rules_array', 'shortcut_filter');

    I’m tring now thanks for the help.
    I’ll post the result here.

    thanks again.

    I am wondering, though, shouldn’t it be $1 and $2 instead of $2 and $3?

    One little question.
    where should I include this functions.php in the template?
    in single.php ?

    No filosofo
    (shortcut) is $1

    thanks for the reply.

    Just stick functions.php in with the other theme files, like index.php, sidebar.php, etc. WP 2.0 includes any functions in it.

    So what’s $3?

    $3 is page. matched by /?

    wow it worked!!!
    thanks for everone for helping me…

    wp rocks!!!

    Could I use something like this to make Simple PHP Gallery 1.1 work with this? in the /gallery/ subdirectory I have the following .htaccess file which makes things act all screwy:

    DirectoryIndex sp_index.php

    RewriteEngine On

    RewriteRule ^folder/(.*) sp_index.php?dir=./$1
    RewriteRule ^file/(.*) sp_index.php?file=./$1
    RewriteRule ^thumb/(.*) sp_getthumb.php?source=$1

    I have tried various combinations of things in a functions.php file but with no luck so far.

    Thanks for your help.

    see this thread for a partial solution to integrating Simple PHP Gallery with mod_rewrite enabled.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Rewrites Rules Does not work with WP 2.0’ is closed to new replies.