Forum Moderators: phranque

Message Too Old, No Replies

Rewrite Rules location?

         

danworld

6:07 am on Jun 1, 2006 (gmt 0)

10+ Year Member



I have all the rewrite rules listed in the "close to perfect .htaccess file" post, but I would like to know where do I put all these rules.

We don't use .htaccess files since we have many virtual hosts. Is there a way to make the rules work server-wide for all the virtual hosts?

jdMorgan

8:46 pm on Jun 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can modify the rule to work in httpd.conf or conf.d by preceding the pattern in the RewriteRule with a slash.

That list is fairly old, and some of those user-agents are defunct. I'd suggest a review of the server logs to see which of them are actually a problem; Then block only those.

Jim

danworld

4:56 am on Jun 2, 2006 (gmt 0)

10+ Year Member



Thanks for the info.

Can you please give me an example how that rule would look like?

So you are saying that by putting this slash, that all these bots will still be denied under the httpd.conf file?

jdMorgan

9:41 pm on Jun 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In .htaccess:

RewriteRule anything - [F]

In httpd.conf

RewriteRule /anything - [F]

.htaccess is used for "per-directory" configuration. Therefore the path to the current directory is stripped before RewriteRule 'sees' it. In the case of your top-level directory, the slash is therefore removed in .htaccess, but needs to be present in http.conf.

Other than that, yes, the rules should work in httpd.conf. But I'd guess you only need 10% of them, and the rest are a waste of CPU time -- Remember that the rules will be processed for each and every HTTP request to your server, that is for every page, image, external script, CSS file, etc. requested from your server.

Restart your server and clear your browser cache after any change to httpd.conf.

Jim