homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

managing htaccess size
better to keep to specific directory

WebmasterWorld Senior Member 10+ Year Member

Msg#: 3546593 posted 2:47 pm on Jan 12, 2008 (gmt 0)

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.



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

Msg#: 3546593 posted 4:57 pm on Jan 12, 2008 (gmt 0)

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.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved