Htaccess File


AddHandler fastcgi-script .py
Options +ExecCGI -Indexes
AddDefaultCharset utf-8
ServerSignature Off
ErrorDocument 404 /404.html

<FilesMatch ".py$">
Order Deny,Allow
Deny from all

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType application/x-javascript text/javascript application/javascript application/json

<IfModule mod_alias.c>
Redirect permanent stuff.html

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# redirect invalid domain names
RewriteCond %{HTTP_HOST} !^(api.|moar.|dev.)?$ [NC]
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

# api commands and docs
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^$ api.html [QSA,L]
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(te?xt|html)$ raw.cgi?format=$1 [QSA,L]
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(te?xt|html).json$ raw.cgi?format=$1&json=1 [QSA,L]

# canonical home url
RewriteCond %{HTTP_HOST} !^(dev.)?$ [NC]

# point the home url to the script
RewriteRule ^$ [R=301,L]

# legacy api
RewriteRule ^moar.(txt|html)$ raw.cgi?format=$1 [QSA,L]
RewriteRule ^moar.(txt|html).json$ raw.cgi?format=$1&json=1 [QSA,L]

# forbid access to python files
RewriteRule .py - [F,L]
Exit mobile version