Created
December 22, 2021 15:53
-
-
Save terryupton/0427103c40e338bae0308273d5b81d8c to your computer and use it in GitHub Desktop.
HTAccess for Craft Sites 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
# ------------------------------------------------------------------------------ | |
# | Exclude directories from the rewrite rules | | |
# ------------------------------------------------------------------------------ | |
# RewriteRule ^eShots - [L] | |
# ------------------------------------------------------------------------------ | |
# | Rewrite engine | | |
# ------------------------------------------------------------------------------ | |
# Turning on the rewrite engine and enabling the `FollowSymLinks` option is | |
# necessary for the following directives to work. | |
Options +FollowSymlinks | |
RewriteEngine On | |
RewriteBase / | |
# ------------------------------------------------------------------------------ | |
# | SETUP ANY SHORT PATHS | | |
# ------------------------------------------------------------------------------ | |
# Redirect 301 /biography.htm /biography/ | |
# RewriteRule ^(.*)\.htm$ $1 [L] | |
# ------------------------------------------------------------------------------ | |
# | Add trailing slash to urls | | |
# ------------------------------------------------------------------------------ | |
RewriteCond %{REQUEST_METHOD} !POST [NC] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$ | |
RewriteRule ^(.*)$ $1/ [R=301,L] | |
# ------------------------------------------------------------------------------ | |
# | CRAFT | | |
# ------------------------------------------------------------------------------ | |
# Send would-be 404 requests to Craft | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC] | |
RewriteRule (.+) index.php?p=$1 [QSA,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment