News for hackers. Stuff that matters.
Re:A collection of useful .htaccess snippets by _cudgel on Monday February 09, 2015 @03:18AM (#9020166)
While I think this is a very valuable resource, and patterns are always welcome by me, it should be noted that the Apache docs recommend against using .htaccess files due to the performance penalty.

From the docs (http://httpd.apache.org/docs/current/howto/htaccess.html):

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.

Re:A collection of useful .htaccess snippets by theblueprint on Monday February 09, 2015 @08:04AM (#9020928)
PSA: Authorization snippets are based on Apache 2.2 config syntax. Care should be taken to review, update and test Authorization config when upgrading to Apache 2.4 (http://httpd.apache.org/docs/2.4/upgrading.html).
Re:A collection of useful .htaccess snippets by DrStalker on Monday February 09, 2015 @03:53AM (#9020250)
These snippets should all be fine to go straight into a directory block, so it's still a really good resource,
Re:A collection of useful .htaccess snippets by tobltobs on Monday February 09, 2015 @09:43AM (#9021339)
Are you sure this is true also for the Rewrite Rules?
Re:A collection of useful .htaccess snippets by _cudgel on Monday February 09, 2015 @04:27AM (#9020320)
I agree completely!
Re:A collection of useful .htaccess snippets by w8rbt on Monday February 09, 2015 @07:25AM (#9020795)
For some hosting situations, the only control you would have would be through the .htaccess file.
Re:A collection of useful .htaccess snippets by lebinh on Monday February 09, 2015 @10:30AM (#9021620)
Cool idea! I've created a similar repo for Nginx from my experiences: https://github.com/lebinh/nginx-conf
Re:A collection of useful .htaccess snippets by csharperer on Monday February 09, 2015 @03:45AM (#9020229)
Pretty sweet! Would love to see something similar for nginx.
Re:A collection of useful .htaccess snippets by keidian on Monday February 09, 2015 @03:24PM (#9023450)
There is some stuff listed at http://wiki.nginx.org/Configuration but it's more laid out in full examples rather than this code block does X
Re:A collection of useful .htaccess snippets by loevborg on Monday February 09, 2015 @03:12AM (#9020149)
The most important thing when it comes to web server configuration is to have a testing setup you understand and that is fully under you're control. That goes twice for working with mod_rewrite.

My recommendation: use only curl -I so caching is ruled out as a problem source. Use a virtual machine that you can reprovision quickly and reliably. Crank up the log level to debug in you apache config. And don't give up!

Re:A collection of useful .htaccess snippets by oneeyedpigeon on Monday February 09, 2015 @05:55AM (#9020559)
The HTML5 boilerplate project also provides a great source for sane apache config:

https://github.com/h5bp/server-configs-apache/blob/master/di...

Re:A collection of useful .htaccess snippets by raziel2p on Monday February 09, 2015 @09:52AM (#9021379)
I think the arguments for www are just as valid, if not more valid, than the arguments against. http://www.yes-www.org/why-use-www/
Re:A collection of useful .htaccess snippets by tux on Monday February 09, 2015 @09:53AM (#9021389)
Thank You :-) Please make nginx one now in similar style and categories. ^_^
Re:A collection of useful .htaccess snippets by emersonrsantos on Monday February 09, 2015 @03:18AM (#9020167)
You can make good http(s) firewalls (albeit not fast as a IP one) against threats.

Needs to add more to this, especially configs against SQL injections and other hacks.

Re:A collection of useful .htaccess snippets by rostigerpudel on Monday February 09, 2015 @04:54AM (#9020401)
Actually, I dont' think that is the webserver's job.

Relying on your webserver to protect you against SQL injection is probably not what you want to do. The webserver has no knowledge at all about what kind of program you run behind it. You would need to teach it everything about what you're doing.

Seriously, you are much better off just using prepared statements everywhere than trying to teach a webserver the finer points of your particular combination of SQL and the language you use. It's like parsing HTML with regular expressions. It might hold up for a while or for certain tasks, but will explode quite unexpectedly at some later point.

Re:A collection of useful .htaccess snippets by krapp on Monday February 09, 2015 @06:33AM (#9020653)
That's true, but sometimes (especially with completely naive or old PHP) 'using prepared statements everywhere' means 'rewriting everything.' In those cases, htaccess might be the only flexible option you have until you can.
Re:A collection of useful .htaccess snippets by theblueprint on Monday February 09, 2015 @08:09AM (#9020946)
Consider ModSecurity with the Core Rule Set (or Trustwave Commercial Rule Set) instead of attempting to repurpose .htaccess files as a substitute WAF.
Re:A collection of useful .htaccess snippets by neoterics on Monday February 09, 2015 @06:33PM (#9024517)
Nice, this is very useful, thanks!
Re:A collection of useful .htaccess snippets by roshansingh on Monday February 09, 2015 @02:26AM (#9020063)
Thanks a lot for making this!