Skip to content

Instantly share code, notes, and snippets.

@acrogenesis
Last active January 3, 2016 08:45
Show Gist options
  • Save acrogenesis/4a7108ff652af2133022 to your computer and use it in GitHub Desktop.
Save acrogenesis/4a7108ff652af2133022 to your computer and use it in GitHub Desktop.
.htaccess hacks
Well i didn't see any thread about this so let's start one :DRINK:
Specify the Directory Index:
DirectoryIndex newindex.html
Specify 404 error:
ErrorDocument 404 /404error.html
Redirect 301
Redirect 301 /old.html /new.html
Resolve www (make www.website.com become website.com)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.website.com [nocase]
RewriteRule ^(.*) http://website.com/$1 [last,redirect=301]
Deny access to specific ip (123.45.6.6)
order allow,deny
deny from 123.45.6.6
allow from all
Prevent Hot linking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?website.com/.*$ [NC]
RewriteRule \.(gif|jpg|css)$ - [F]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment