Merge branch 'skilledDeveloper-master'

This commit is contained in:
An Phan 2015-02-24 17:10:26 +08:00
commit 9caa4efbc1
1 changed files with 22 additions and 2 deletions

View File

@ -34,10 +34,13 @@ What we are doing here is mostly collecting useful snippets from all over the in
- [Disable Image Hotlinking for Specific Domains](#disable-image-hotlinking-for-specific-domains) - [Disable Image Hotlinking for Specific Domains](#disable-image-hotlinking-for-specific-domains)
- [Password Protect a Directory](#password-protect-a-directory) - [Password Protect a Directory](#password-protect-a-directory)
- [Password Protect a File or Several Files](#password-protect-a-file-or-several-files) - [Password Protect a File or Several Files](#password-protect-a-file-or-several-files)
- [Block Visitors by Referrer](#block-visitors-by-referrer)
- [Prevent Framing the Site](#prevent-framing-the-site)
- [Performance](#performance) - [Performance](#performance)
- [Compress Text Files](#compress-text-files) - [Compress Text Files](#compress-text-files)
- [Set Expires Headers](#set-expires-headers) - [Set Expires Headers](#set-expires-headers)
- [Turn eTags Off](#turn-etags-off) - [Turn eTags Off](#turn-etags-off)
- [Disable gzip Compression](#disable-gzip-compression)
- [Miscellaneous](#miscellaneous) - [Miscellaneous](#miscellaneous)
- [Set PHP Variables](#set-php-variables) - [Set PHP Variables](#set-php-variables)
- [Custom Error Pages](#custom-error-pages) - [Custom Error Pages](#custom-error-pages)
@ -283,6 +286,24 @@ Require valid-user
</FilesMatch> </FilesMatch>
``` ```
### Block Visitors by Referrer
This denies access for all users who are coming from (referred by) a specific domain.
[Source](http://www.htaccess-guide.com/deny-visitors-by-referrer/)
``` apacheconf
RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} somedomain\.com [NC,OR]
RewriteCond %{HTTP_REFERER} anotherdomain\.com
RewriteRule .* - [F]
```
### Prevent Framing the Site
This prevents the website to be framed (i.e. put into an `iframe` tag), when still allows framing for a specific URI.
``` apacheconf
SetEnvIf Request_URI "/starry-night" allow_framing=true
Header set X-Frame-Options SAMEORIGIN env=!allow_framing
```
## Performance ## Performance
### Compress Text Files ### Compress Text Files
``` apacheconf ``` apacheconf
@ -390,7 +411,6 @@ By removing the ETag header, you disable caches and browsers from being able to
FileETag None FileETag None
``` ```
## Miscellaneous ## Miscellaneous
### Set PHP Variables ### Set PHP Variables
@ -478,4 +498,4 @@ RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1] RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
``` ```
[Source](https://github.com/vincentorback/WebP-images-with-htaccess) [Source](https://github.com/vincentorback/WebP-images-with-htaccess)