.htaccess dynamic subdomain slow

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

  1. #1
    Hello all - 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

    Thanks!
     
    ccoonen, Aug 20, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This probably has nothing to do with the htaccess. Htaccess is very fast and they only need to do some regexes, then redirect to the resulting one. More likely is that your county.php & state.php files are slow due to whatever reason (mysql most likely). Try just executing the the php file directly : yoursite.com/country.php?site=fillthisin&statename=xxx&id=yyy
     
    premiumscripts, Aug 20, 2009 IP
  3. pepprs

    pepprs Peon

    Messages:
    195
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yea i second that.. i dont think your htaccess is the problem. Check your response times for the county and state php files and see if any part of can be cacheable. it can improve performance.
     
    pepprs, Aug 20, 2009 IP
  4. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #4
    Thats what i thought first, but i ran it through charles... and it doesn't even start executing the page... i think the page render/code is fast and clean - but you could be right - I'll analyze that first thanks guys!
     
    ccoonen, Aug 21, 2009 IP
  5. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #5
    it's definitely not the htaccess. Think about it. You're saying the fourth is way faster than the first?

    All the htaccess does is this:

    If it matches ^([-a-zA-Z]+)?$ it goes to x.php
    If it matches ^city/([-a-zA-Z]+)/([-a-zA-Z]+)/([-a-zA-Z]+)/([0-9]+)/([0-9]+)/?$ it goes to y.php

    htaccess does not care about x or y.php, that's afterwards. All htaccess does is tell the server where to look, then it's up to php again. Definitely a php issue.
     
    premiumscripts, Aug 21, 2009 IP