Mod rewrite errors since apache 2.2.10 update

Discussion in 'Apache' started by fortunegeek, Nov 17, 2008.

  1. #1
    I have a website that is no longer functioning due to my hosting companies upgrade to Apache web server to version 2.2.10 (from 1.3.4x). The problem is in the .htaccess file.

    This is the file;

    # Version: 1.02 (03.07.2004.)
    # Options +FollowSymLinks
    RewriteEngine on
    #RewriteBase /

    RewriteRule ^admin/$ admin/index.php [L]
    RewriteRule ^/$ index.php?req=search [L]

    RewriteRule ^paid/(.*)$ index.php?req=paid&id=$1 [L]

    RewriteRule ^scripts/(.*)/(.*).html$ index.php?req=cat&id=$1&offs=$2 [L]
    RewriteRule ^scripts/(.*)$ index.php?req=cat&id=$1 [L]
    RewriteRule ^add/(.*)$ index.php?req=add&id=$1 [L]
    RewriteRule ^confirm/([^/]+)/(.*)$ index.php?req=confirm&memb_id=$1&code=$2 [L]
    RewriteRule ^detailed/(.*).html$ index.php?req=detailed&id=$1 [L]
    RewriteRule ^pages/(.*).html$ index.php?req=pages&id=$1 [L]
    RewriteRule ^addreview/(.*)$ index.php?req=addreview&id=$1 [L]
    RewriteRule ^reviews/(.*)$ index.php?req=reviews&id=$1 [L]
    RewriteRule ^subscribe/(.*)$ index.php?req=subscribe&id=$1 [L]
    RewriteRule ^news/(.*)$ index.php?req=news_read&id=$1 [L]

    RewriteRule ^register\.html$ index.php?req=register [L]
    RewriteRule ^login\.html$ index.php?req=login [L]
    RewriteRule ^logout\.html$ index.php?req=logout [L]
    RewriteRule ^members\.html$ index.php?req=members [L]
    RewriteRule ^modify\.html$ index.php?req=modify [L]
    RewriteRule ^modify/(.*)$ index.php?req=modify&id=$1 [L]
    RewriteRule ^refer/(.*)$ index.php?req=refer&id=$1 [L]
    RewriteRule ^report/(.*)$ index.php?req=report&id=$1 [L]
    RewriteRule ^popular\.html$ index.php?req=popular [L]
    RewriteRule ^top\.html$ index.php?req=top [L]
    RewriteRule ^new\.html$ index.php?req=new [L]
    RewriteRule ^new/([^/]+)/(.*)/(.*).html$ index.php?req=new&id=$1&day=$2&offs=$3 [L]
    RewriteRule ^new/([^/]+)/(.*)$ index.php?req=new&id=$1&day=$2 [L]

    RewriteRule ^addrelated\.html$ index.php?req=addrelated [L]
    RewriteRule ^resendcode\.html$ index.php?req=resendcode [L]
    RewriteRule ^emailpass\.html$ index.php?req=emailpass [L]
    RewriteRule ^usersettings\.html$ index.php?req=usersettings [L]
    RewriteRule ^search\.html$ index.php?req=advancedsearch [L]
    RewriteRule ^link\.html$ index.php?req=link_to_us [L]
    RewriteRule ^aboutus\.html$ index.php?req=aboutus [L]
    RewriteRule ^sitemap\.html$ index.php?req=sitemap [L]
    RewriteRule ^advertise\.html$ index.php?req=advertise [L]

    RewriteRule ^rss/(.*)$ rss.php?$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)/(.*).html$ index.php?req=cat&id=$1&offs=$2 [L]

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)/index\.html$ index.php?req=cat&id=$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)/$ index.php?req=cat&id=$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)\.html$ index.php?req=detailed&id=$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)$ index.php?req=cat&id=$1 [L]

    <Files ~ "License Number.txt">
    Order allow,deny
    Deny from All
    </Files>
    # set the server timezone
    SetEnv TZ America/New_York

    AddCharset iso-8859-1 .html
    AddCharset iso-8859-1 .php

    <Files 403.shtml>
    order allow,deny
    allow from all
    </Files>

    Since the upgrade to the new version of Apache the website hardly loads, images dont show and things crawl along.

    I have located that this specific part causes the issues.

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)/(.*).html$ index.php?req=cat&id=$1&offs=$2 [L]

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)/index\.html$ index.php?req=cat&id=$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)/$ index.php?req=cat&id=$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)\.html$ index.php?req=detailed&id=$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-D
    RewriteRule ^(.*)$ index.php?req=cat&id=$1 [L]

    Contacting the host has given me this - "We've placed the rewrite rules in place and we are seeing that they do work but we're seeing the same slowness that you're indicating. Unfortunately due to the complexity of regex in mod_rewrite rules we support mod_rewrite on the servers but the actual regex and rules themselves is something that we can't directly support and is outside the scope of our normal support so this is something you'll need to investigate and address due to this."

    Isnt that nice? Hope someone here can help me out as the site is not functioning :(
     
    fortunegeek, Nov 17, 2008 IP
  2. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #2
    2 years ago I migrated myself rom apache 1.3 to 2.2.x and had most severe mod_rewrite problems ( nothing worked to be precise )

    here is what I needed to change in my apache 2.2 mod_rewrite for all to work again

    I see for example that you have your
    # Options +FollowSymLinks
    OUTcommented
    .......
    may be above helps. I had NOTHING in my rather complex regex to change, just the apache config to adapt since 1.3 handled several major config parts in different files than 2.2.
    now all works perfect since 2+ years
    Good luck
     
    hans, Nov 18, 2008 IP
  3. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #3
    They gave you a generic answer because they know it's going to take an hour for someone they have to pay $50+ an hour just to decipher what your rewrites are doing. Helpdesk monkeys usually aren't qualified to do anything other than click buttons.

    I'm going to take a shot in the dark and suggest replacing all instances of ^ that are followed by a letter with ^/? then replacing "^/$" with "^/?$" and pray that it's the leading slash change between your Apache versions.

    Like I said, this is a shot in the dark and I don't want to take the time to pick that code apart, make a backup first.
     
    joebert, Nov 18, 2008 IP