Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Cooperx http://www.petercooper.co.uk/

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Making symbolic linked Rails apps work when folder accessed with no trailing slash

Snippets is at bigbold.com/snippets/ but bigbold.com/snippets always failed with "Bad Request". bigbold.com/snippets always seemed to rewrite into 'snippets.html' for some reason, so this change to .htaccess cures it:

   1  RewriteCond %{REQUEST_FILENAME} !-f
   2  RewriteCond %{REQUEST_FILENAME} !snippets\.html
   3  RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
   4  RewriteRule snippets\.html /snippets/ [R]


Replace snippets with the name of your own folder, obviously.

Block Google Web Accelerator with .htaccess and mod_rewrite

By Shane Allen.

   1  RewriteEngine On
   2  RewriteCond %{HTTP_X_MOZ} ^prefetch$
   3  RewriteRule ^.*$ - [F]

Prevent yourself from getting Slashdotted

Assuming you have mod_rewrite and AllowOverride activated, throw this in the .htaccess file for the directory you don't want to be Slashdotted:

   1  RewriteEngine On
   2  RewriteCond %{HTTP_REFERER} ^.*slashdot.*$
   3  RewriteRule .* - [F]


This all assumes the editors actually check the links before posting the story, but this should reasonably mean no-one on Slashdot can link to you, even if it's a bit over the top.
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS