Need help optimizing MONSTER 400 line .htaccess

Discussion in 'Site & Server Administration' started by webtracker, Jan 21, 2007.

  1. #1
    I purchased a site a few months back and the .htaccess file, which was already big, is getting BIGGER...

    I don't really know enough about this sort of thing so I was hoping for some guidance from someone that does.

    Here's an idea of what it looks like:

    Top part:

    ErrorDocument 404 /index.php

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www.MYSITE.com$ [NC]
    RewriteRule ^(.*)$ http://www.MYSITE.com/$1 [L,R=301]

    The rest - Pretty much the same REWRITE rule for the rest of the file x (times) the number of folders that I happen to have/create:

    RewriteRule ^directoryspanish01/subdirectory/([0-9]+)/page/([0-9]+) index.php?app=directoryspanish01&action=subdirectory&cat_id=$1&pageNum=$2 [L]

    RewriteRule ^directoryenglish01/subdirectory/([0-9]+)/page/([0-9]+) index2.php?app=directoryenglish01&action=subdirectory&cat_id=$1&pageNum=$2 [L]


    That's it. Everytime I create a new folder I need to add a RewriteRule to the .htaccess. If I don't, and try to access that page, it's redirected to the home page.

    Is the length of the .htaccess something that I should be concerned with? Any ideas on how to shorten it? It's getting LONG...

    Thanks
     
    webtracker, Jan 21, 2007 IP
  2. mdvaldosta

    mdvaldosta Peon

    Messages:
    4,079
    Likes Received:
    362
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It could (slightly) slow your site down if you're getting a ton of traffic since I believe it has to get parsed before each page load. I've got a site with an .htaccess about that size (big site that gets alot of referrer spam), never noticed any speed difference though.

    I'm sure there has to be a simple way to use wildcards or something in your rewrite lines, someone like Nintendo would be helpful. Something so you don't have to add new lines for each new subfolder.
     
    mdvaldosta, Jan 21, 2007 IP