WordPress.org

Forums

[resolved] Rewrites Rules Does not work with WP 2.0 (10 posts)

  1. argiope
    Member
    Posted 9 years ago #

    Hello,

    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.
    Ron.

  2. Austin Matzko
    Member
    Posted 9 years ago #

    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');

  3. argiope
    Member
    Posted 9 years ago #

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

    thanks again.

  4. Austin Matzko
    Member
    Posted 9 years ago #

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

  5. argiope
    Member
    Posted 9 years ago #

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

  6. argiope
    Member
    Posted 9 years ago #

    No filosofo
    (shortcut) is $1

    thanks for the reply.

  7. Austin Matzko
    Member
    Posted 9 years ago #

    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?

  8. argiope
    Member
    Posted 9 years ago #

    $3 is page. matched by /?

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

    wp rocks!!!

  9. mailman0
    Member
    Posted 9 years ago #

    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.

  10. mailman0
    Member
    Posted 9 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic