Skip to content

Instantly share code, notes, and snippets.

@terryupton
Created December 22, 2021 15:53
Show Gist options
  • Save terryupton/0427103c40e338bae0308273d5b81d8c to your computer and use it in GitHub Desktop.
Save terryupton/0427103c40e338bae0308273d5b81d8c to your computer and use it in GitHub Desktop.

Revisions

  1. terryupton created this gist Dec 22, 2021.
    40 changes: 40 additions & 0 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    <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>