Is it okay to have a very long .htaccess file?

No, it's not OK and will hamper your page-load speed.

.htaccess files are evaluated on EVERY server request. Even for static images, CSS and JS files. So, you're asking the webserver to parse 1000+ long possibly REGEX lines while executing a request.

Also, parent directory's .htaccess file is processed for files residing in subdirectory too. So, if your large .htaccess is in root directory of website, then it will be processed for all requests made for files in the subdirectories too (along with the .htaccess file in subdirectory).

That my friend is a lot of processing. If you have a page with 10 images (for example) it gets processes 11 times. And the more processing in the file, then the more cycles it takes. So yes, anything in a htaccess file has an impact. Now is that impact noticeable? It is hard to say when it becomes an issue. But it would have to be pretty big as the processing in relatively simple, which in your case is.

The key with an htaccess file is to make it smart. You would not want to list 200 entries. You can so it smart with just a few lines (if you want to use htaccess).


I would perform a simple test: generate a large .htaccess file with random URLs, and measure the resulting performance yourself.

import random,string

def rand_string():
    length = random.randint(4,10)
    res = []
    for i in range(length):
        res.append(random.choice(string.letters))
    return ''.join(res)

for i in range(1000):
    print "RewriteRule %s http://www.mydomain.com/boring.php?%s [R]" % \
     (rand_string(), rand_string())