.htaccess dynamic subdomain slow

Discussion in 'Apache' started by ccoonen, Aug 20, 2009.

  1. #1
    Sorry folks, I put this in PHP first... but I think it belonged in here - but anyways, here it is:

    I have a wildcard DNS and am using this .htaccess

    Options +FollowSymLinks

    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^www\.tooth-info\.com$ [NC]
    RewriteRule ^([-a-zA-Z]+)?$ state.php?site=%{HTTP_HOST}&id=$1 [NC,L]
    RewriteRule ^state/([-a-zA-Z]+)/([0-9]+)/?$ county.php?site=%{HTTP_HOST}&statename=$1&id=$2 [NC,L]
    RewriteRule ^county/([-a-zA-Z]+)/([-a-zA-Z]+)/([0-9]+)/?$ city.php?site=%{HTTP_HOST}&statename=$1&countyname=$2&id=$3 [NC,L]
    RewriteRule ^city/([-a-zA-Z]+)/([-a-zA-Z]+)/([-a-zA-Z]+)/([0-9]+)/([0-9]+)/?$ information.php?site=%{HTTP_HOST}&statename=$1&countyname=$2&cityname=$3&id=$4&countyid=$5 [NC,L]

    The issue is - city is very fast, county is medium, state and anything else is very slow. So it takes forever for the first rewriterule, faster for the second rewriterule, third is even faster, and fourth is the fastest - the first one takes like 10 seconds to parse and even start hitting the page...

    Any assistance is appreciated! thanks - also, removing the NC (Non-case sensitive) doesn't help
     
    ccoonen, Aug 20, 2009 IP
  2. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i'm not sure about this: "[-a-zA-Z]+" is it correct? i would have thought "[a-zA-Z]+".
     
    szalinski, Aug 21, 2009 IP
  3. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Wow, i think your right - but somehow its working, lol
     
    ccoonen, Aug 21, 2009 IP
  4. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The "Regex Coach" says:

    and btw: your = belonging to you; you're = you are ;) Mentioned simply because we seem to carry our faults from one place to the next (the English language -> regular expressions).
     
    szalinski, Aug 21, 2009 IP