-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy path.htaccess
More file actions
48 lines (37 loc) · 1.43 KB
/
.htaccess
File metadata and controls
48 lines (37 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Enable URL rewriting
RewriteEngine On
# If the request was made to 50.251.58.13, redirect to imagemagick.org
RewriteCond %{HTTP_HOST} ^50\.251\.58\.13$
RewriteRule ^(.*)$ https://imagemagick.org/ [R=301,L]
# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.imagemagick\.org [NC]
RewriteRule ^(.*)$ https://imagemagick.org/$1 [L,R=301]
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect any request that starts with /Usage
RewriteCond %{REQUEST_URI} ^/Usage
RewriteRule ^(.*)$ https://usage.imagemagick.org/ [R=301,L]
# Set MIME types for ebook and media files
AddType application/epub+zip .epub
# Prevent directory listing
# Options -Indexes
# Cache static files for performance
<FilesMatch "\.(pdf|epub|mp4|webp|jpg|jpeg|png|gif|css|js)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
# Protect .htaccess itself
<Files .htaccess>
Order Allow,Deny
Deny from all
</Files>
# Prevent hotlinking of media files
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://(www\.)?imagemagick\.org/ [NC]
RewriteRule \.(pdf|epub|mp4|webp|jpg|jpeg|png|gif)$ - [F]
# On download.imagemagick.org, only allow the /archive path
RewriteCond %{HTTP_HOST} ^download\.imagemagick\.org$ [NC]
RewriteCond %{REQUEST_URI} !^/archive(?:/|$) [NC]
RewriteRule ^(.*)$ https://download.imagemagick.org/archive/ [R=301,L]
# Custom 404 error page
# ErrorDocument 404 /404.html