• Hi All
    I have a question about mod_rewrite. One of the autogenerated rules I have is

    RewriteRule ^archives/([0-9]{4})?/?([0-9]{1,2})?/?([0-9]{1,2})?/?([_0-9a-z-]+)?/?([0-9]+)?/?$ /blog/index.php?year=$1&monthnum=$2&day=$3&name=$4&page=$5 [QSA]

    Now my question is would this rule work only for
    /archives/2004/05/15/postslug/
    or will also work for
    /archives/2004/05/15/ for all posts on May 15
    /archives/2004/05/ for all posts in May 2004
    and so on. I am asking this because on my blog at https://pnarula.com/blog last one is used for Montly Archives and it is not working. While it works for individual posts.
    Help is very much appreciated.
    Cheers
    Pankaj

Viewing 9 replies - 1 through 9 (of 9 total)
  • I guess the &’s come from posting because they shouldn’t be in your htaccess.
    Anayway, I have the same kind of trouble with the generated htaccess rule with the following ‘solution’:
    if I remove “page=$5”
    the rule starts working for posts
    if I also remove “name=$4”
    the rule starts working for daily archives
    if I also remove “day=$3”
    the rule starts working for monthly archives
    etc…
    hmm.

    Thread Starter pankaj

    (@pankaj)

    Negative, even changing it to “Show the most recent 5 POSTS PAGED” in the Reading Options it does the exactly the same.
    I am using RC1.
    Pankaj

    Pankaj,
    I’m also hosted on hostforweb and having the same problems you describe. The only thing I can think of at this moment is that they have suphp installed on (most of) their servers and that this CGI wrapper is somehow disturbing the modrewrite rules. However suphp isn’t supposed to do that.
    Problem is that I’m neither a suphp nor a htaccess/modrewrite specialist.

    Thread Starter pankaj

    (@pankaj)

    Thomas
    I also did the same. Now my individual, and daily archives seems to be working. But it still is a no go for monthly and yearly archives. Here are my rewrite rules
    RewriteRule ^archives/([0-9]{4})?/?$ /blog/index.php?year=$1 [QSA]
    RewriteRule ^archives/([0-9]{4})?/?([0-9]{1,2})?/?$ /blog/index.php?year=$1&monthnum=$2 [QSA]
    RewriteRule ^archives/([0-9]{4})?/?([0-9]{1,2})?/?([0-9]{1,2})?/?$ /blog/index.php?year=$1&monthnum=$2&day=$3 [QSA]
    RewriteRule ^archives/([0-9]{4})?/?([0-9]{1,2})?/?([0-9]{1,2})?/?([_0-9a-z-]+)?/?$ /blog/index.php?year=$1&monthnum=$2&day=$3&name=$4 [QSA]
    RewriteRule ^archives/([0-9]{4})?/?([0-9]{1,2})?/?([0-9]{1,2})?/?([_0-9a-z-]+)?/?([0-9]+)?/?$ /blog/index.php?year=$1&monthnum=$2&day=$3&name=$4&page=$5 [QSA]
    Please notice the difference in position of ? in the source rules. You use ? just at the end for all except year while I enclose at both the ends for all except year. You donot have ? at the end of year while I do. I did try making them the way you wrote but even that was not working, so I switched them back to this.
    Thanks for the continued help.
    Pankaj

    pankaj, you seem to have gotten it working. What was your final solution?

    I’m suffering from the same problem:
    Wordpress is installed at a subdirectory:
    https://www.whisperingwords.net/wptest/wordpress/
    The blog is at:
    https://www.whisperingwords.net/wptest/
    I’ve tested mod_rewrite and confirmed with my host that it is present. I have set up my archives to show:
    /archives/%Year%/%monthnum%/%postname%/
    and categories as:
    /archives/
    The categories work fine. The monthly archives returns “Sorry, no posts match your criteria”, and so does the individual entry pages.
    When I get rid of the “/archives/” bit or put “/index.php/archives…”, the darn thing starts working fine. It’s driving me quite batty, especially as yours truly is primarily a law student and considers mod_rewrite a form of the black arts.
    I’d really appreciate some help here… I’m evaluating WP as an alternative to MT (given the licensing restrictions), and so far WP seems nice but the frustration of the crazy permalinks is driving me up the wall.
    Thanks.

    I’m having the same problem…
    If you change the category to something different from the archives, say archives2, it works fine. My guess is that for some reason they can’t have the same directory name for both of them.

    I’m low on information but you might try putting the individual-post line at the bottom of your .htaccess file (the one saying something like:RewriteRule ^archives/?(.*) /wordpress/index.php?category_name=$1 [QSA] )
    Basicly what I think is happening: your individual post line takes all incoming orders because they all match.
    some notes on functioning htaccess (as I perceive it ?? :
    1 checks the condition: ^archives/?(.*)
    2 applies the rewrite: /wordpress/index.php?category_name=$1
    3 checks the other conditions with this new uri (the rewritten one)
    In general it will help every wordpress site to have every line of the htaccess flagged by: [QSA,NC,L] instead of just [QSA]
    L meaning that server stops processing the htaccess file if the condition is met: thus making the site a little faster
    NC meaning that if somebody types your uri with one or more cApitaLs the uri still works
    hope this helps!

    For law students interested in the black arts that go by the name of Lashlar (which in it self sounds like the name of a successful magician)
    https://www.sitepoint.com/article/guide-url-rewriting/1
    https://httpd.apache.org/docs-2.0/mod/mod_rewrite.html
    https://www.engelschall.com/pw/apache/rewriteguide/

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Another mod_rewrite question’ is closed to new replies.