.htaccess size

Discussion in 'Apache' started by mlammin, May 16, 2007.

  1. #1
    I'm new to creating .htaccess files. Is there a recommeneded max size or no. of lines? Would a file with, say 5000 lines have a noticeable effect on performance? If so, would this be adequately countered by upgrading from a shared to a dedicated server?
     
    mlammin, May 16, 2007 IP
  2. cyanide

    cyanide Peon

    Messages:
    483
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try it, see what happens :)

    Bu yes it can degrade performance of your site. I would think that it's pretty difficult to say and would depend on what exactly you've got in there.

    Only one sure way to find out
     
    cyanide, May 16, 2007 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    Post a few examples. Maybe we can shrink that from 5000 rewrite lines to...1!! :eek:
     
    Nintendo, May 16, 2007 IP
  4. mlammin

    mlammin Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OK:

    RewriteEngine on
    RewriteRule magicians/act-name /profile.php?id=1
    RewriteRule magicians/act-name /profile.php?id=2
    RewriteRule comedians/act-name /profile.php?id=3
    RewriteRule hypnotists/act-name /profile.php?id=4
    RewriteRule bands/jazz-bands/act-name profile.php?id=5
    RewriteRule bands/jazz-bands/act-name profile.php?id=6
    RewriteRule bands/reggae-bands/act-name profile.php?id=7

    All the 'act-name's wouls be unique. Only 'bands' wouls have an additional subcat. profile.php pulls all data (including cat, sub-cat and act-name) from a mysql db.

    I think I could write a script to automatically generate an .htaccess file in the above format.

    I wouldn't have a clue how you would reduce this down but if you've got any ideas......

    I know there's regular expressions, but it's rocket science to me.
     
    mlammin, May 17, 2007 IP
  5. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you're not using any other URL rewriting (other than to go to the profile.php script), you could set it up so that for every request where a real file of that name does not exist gets rewritten to the profile.php script. You can then edit your profile.php to parse the URL and lookup the corresponding profile.

    Alternatively you could keep the ID itself in the generated URLs so that they would be in the format cat/subcat(optional)/id/name - and that would only need one rewrite rule.
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^[^/]+/([^/]+/)?([0-9]+)/[^/]+$ /profile.php?id=$2 [L]

    First two lines just check if the requested file exists and stops rewriting if it does.
     
    rodney88, May 17, 2007 IP
  6. mlammin

    mlammin Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for your reply rodney88. I noticed from your glype.com site you offer a paid mod_rewrite service.

    My site is still in the development stage, but I'd like to contact you in a month or 2 for a quote to look at the best solution to this, if that's ok.
     
    mlammin, May 17, 2007 IP