Welcome to WebmasterWorld Guest from 54.166.122.69

Forum Moderators: Ocean10000 & incrediBILL & phranque

managing htaccess size

better to keep to specific directory

   
2:47 pm on Jan 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was wondering if theres any thoughts on these two ways of managing redirects and 410's.

Place all code in one main htaccess file in the root directory meaning its grows quite large and every request has to read it. Split the file up so you only place each redirect or wotever code in the specific directory the file would be called from.

4:57 pm on Jan 12, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



It's a trade-off between file size and maintainability. On the one hand, you might say, "let the computers do the work" in order to get the benefit of centralized administration, while on the other, you might be more concerned with reducing the work that the server must do to handle each request.

Depending on your traffic, an .htaccess filesize of 250KB might be acceptable, while on a very busy site, a 75KB .htaccess file might introduce a noticeable delay in serving pages.

There are some other "middle of the road" techniques as well. For example, you might add logic to your 410-Gone ruleset to skip processing if the request is not for a particular list of subdirectories. Or skip proicessing if the request is not for "page" filetypes. For example:


RewriteCond %{REQUEST_URI} ^/removed-page1\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/removed-page2\.htm$ [OR]
RewriteCond %{REQUEST_URI} ^/removed-page3\.shtml$ [OR]
RewriteCond %{REQUEST_URI} ^/removed-page4\.shtm$ [OR]
RewriteCond %{REQUEST_URI} ^/removed-page5\.php$ [OR]
RewriteCond %{REQUEST_URI} ^/removed-page6\.php5$
RewriteRule \.(s?html?¦php[1-5]?)$ - [G]

Here, all of the RewriteConds are skipped unless the request is for a "page" filetype, due the way that mod_rewrite processes RewriteConds only if the RewriteRule pattern matches (see documentation). As a result, the majority of requests to the site --usually requests for images, CSS, etc.-- will not require the RewriteConds to be processed.

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month