116 lines
3.9 KiB
Text
116 lines
3.9 KiB
Text
---
|
|
permalink: "/.htaccess"
|
|
layout: null
|
|
eleventyExcludeFromCollections: true
|
|
excludeFromSitemap: true
|
|
---
|
|
RewriteEngine On
|
|
|
|
Options -Indexes
|
|
|
|
DirectoryIndex index.php index.html
|
|
|
|
# serve directory index files directly (index.html)
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
|
RewriteCond %{REQUEST_FILENAME}/index.html -f
|
|
RewriteRule ^(.*)$ $1/index.html [L]
|
|
|
|
# serve directory index files directly (index.php)
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
|
RewriteCond %{REQUEST_FILENAME}/index.php -f
|
|
RewriteRule ^(.*)$ $1/index.php [L]
|
|
|
|
ErrorDocument 403 /403/index.html
|
|
ErrorDocument 404 /404/index.html
|
|
ErrorDocument 429 /429/index.html
|
|
ErrorDocument 500 /500/index.html
|
|
|
|
# dynamic page routing
|
|
|
|
## artists
|
|
RewriteRule ^music/artists/([^/]+)/?$ music/artists/index.php [L]
|
|
|
|
## books
|
|
RewriteRule ^books/([^/]+)/?$ books/index.php [L]
|
|
RewriteRule ^books/years/(\d{4})/?$ books/years/index.html [L]
|
|
RewriteRule ^books/?$ books/books.html [L]
|
|
|
|
## movies
|
|
RewriteRule ^watching/movies/([^/]+)/?$ watching/movies/index.php [L]
|
|
|
|
## shows
|
|
RewriteRule ^watching/shows/([^/]+)/?$ watching/shows/index.php [L]
|
|
|
|
## genres
|
|
RewriteRule ^music/genres/([^/]+)/?$ music/genres/index.php [L]
|
|
|
|
## tags
|
|
RewriteRule ^tags/([^/]+)(?:/([0-9]+))?/?$ tags/index.php [L]
|
|
|
|
## open graph assets
|
|
RewriteRule ^og/([a-z0-9\-]+)/([\d\.]+)/([a-f0-9\-]+)\.([a-z0-9]+)$ /api/og-image.php?id=$3&class=$1&v=$2&extension=$4 [L]
|
|
|
|
{% for redirect in redirects -%}
|
|
Redirect {{ redirect.status_code | default: "301" }} {{ redirect.source_url }} {{ redirect.destination_url }}
|
|
{% endfor -%}
|
|
|
|
{% for pathData in headers %}
|
|
<FilesMatch "{{ pathData.resource_path }}">
|
|
{%- for header in pathData.headers %}
|
|
Header set {{ header.header_name }} "{% if header.header_name == "Content-Disposition" and header.header_value contains 'filename="' %}{{ header.header_value | replace: '"', '' }}{% else %}{{ header.header_value }}{% endif %}"
|
|
{%- endfor %}
|
|
</FilesMatch>
|
|
{% endfor %}
|
|
|
|
{%- assign userAgents = "" -%}
|
|
{% for robot in robots -%}
|
|
{%- for userAgent in robot.user_agents -%}
|
|
{%- if userAgent != "*" and userAgent != "NaN" -%}
|
|
{%- assign userAgents = userAgents | append: userAgent %}
|
|
{%- unless forloop.last -%}
|
|
{%- assign userAgents = userAgents | append: "|" -%}
|
|
{%- endunless -%}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- endfor %}
|
|
{% if userAgents != "" or referers != "" -%}
|
|
RewriteCond %{HTTP_USER_AGENT} "{{ userAgents }}" [NC]
|
|
RewriteCond %{REQUEST_URI} !^/robots\.txt$ [NC]
|
|
RewriteRule .* /403/index.html [L,R=403]
|
|
{%- endif %}
|
|
|
|
<IfModule mod_deflate.c>
|
|
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json application/font-woff2
|
|
</IfModule>
|
|
|
|
<IfModule mod_brotli.c>
|
|
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript application/json application/font-woff2
|
|
</IfModule>
|
|
|
|
<IfModule mod_expires.c>
|
|
ExpiresActive On
|
|
ExpiresDefault "access plus 1 month"
|
|
ExpiresByType application/font-woff2 "access plus 1 year"
|
|
ExpiresByType text/html "access plus 1 hour"
|
|
ExpiresByType text/css "access plus 1 week"
|
|
ExpiresByType application/javascript "access plus 1 week"
|
|
ExpiresByType image/jpeg "access plus 1 month"
|
|
ExpiresByType image/png "access plus 1 month"
|
|
ExpiresByType image/gif "access plus 1 month"
|
|
ExpiresByType image/svg+xml "access plus 1 month"
|
|
ExpiresByType image/x-icon "access plus 1 year"
|
|
ExpiresByType application/json "access plus 1 week"
|
|
ExpiresByType application/octet-stream "access plus 1 month"
|
|
ExpiresByType font/ttf "access plus 1 year"
|
|
ExpiresByType font/otf "access plus 1 year"
|
|
ExpiresByType application/wasm "access plus 1 year"
|
|
</IfModule>
|
|
|
|
<IfModule mod_headers.c>
|
|
<FilesMatch "\.(css|js|woff2)$">
|
|
Header set Cache-Control "public, max-age=31536000"
|
|
</FilesMatch>
|
|
<FilesMatch "\.(html|htm)$">
|
|
Header set Cache-Control "public, max-age=3600, must-revalidate"
|
|
</FilesMatch>
|
|
</IfModule>
|