Skip to content

Instantly share code, notes, and snippets.

@DerZyklop DerZyklop/.htaccess
Last active Oct 12, 2018

Embed
What would you like to do?
Kirby .htaccess
# Kirby .htaccess for Projects by DerZyklop
# Source: https://gist.github.com/DerZyklop/609d1e0245c798ceccec7c7fba660041
# Deflate Compression by MimeType
<IfModule mod_deflate.c>
<FilesMatch "\.(js|jpg|jpeg|gif|png|css)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
# rewrite rules
<IfModule mod_rewrite.c>
# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on
# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /mysite
#
RewriteBase /
# Redirect to https
#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
# Remove www.
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
# Add www.
#RewriteCond %{HTTP_HOST} !^www. [NC]
#RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
# Route all domains to http://domain.tld/
#RewriteCond %{HTTP_HOST} !^domain\.com$ [NC]
#RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]
# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) index.php [L]
# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) index.php [L]
# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]
# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
</IfModule>
# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.