-
-
Save Natetronn/3439411 to your computer and use it in GitHub Desktop.
Extended ExpressionEngine .htaccess
This file contains 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
# Secure .htaccess file | |
# ------------------------------ | |
<Files .htaccess> | |
order allow,deny | |
deny from all | |
</Files> | |
# Don't show any directory without an index file | |
# ------------------------------ | |
Options -Indexes | |
# Dont list files in index pages | |
# ------------------------------ | |
IndexIgnore * | |
# EE 404 Page for Missing Pages | |
# "/pages/404" May differ depending on where your template is located. | |
# ------------------------------ | |
ErrorDocument 404 /index.php?/pages/404 | |
# Simple 404 for missing files | |
# ------------------------------ | |
<FilesMatch "(\.jpe?g|gif|png|bmp|css|js|flv)$"> | |
ErrorDocument 404 "File Not Found" | |
</FilesMatch> | |
# Remove IE image toolbar | |
# ------------------------------ | |
<FilesMatch "\.(html|htm|php)$"> | |
Header set imagetoolbar "no" | |
</FilesMatch> | |
# Rewrite Magic | |
# ------------------------------ | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
# WWW: Remove the www from the URL | |
# ------------------------------ | |
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] | |
# RewriteRule ^(.*)$ http://%1/$1 [NC,R=301] | |
# WWW: Force the www | |
# ------------------------------ | |
# RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC] | |
# RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [NC,R=301] | |
# SLASHES: Remove the trailing slash to paths without an extension | |
# ------------------------------ | |
# RewriteCond %{REQUEST_METHOD} !=POST [NC] | |
# RewriteCond %{REQUEST_URI} /$ [NC] | |
# RewriteCond %{REQUEST_FILENAME} !-f [NC] | |
# RewriteCond %{REQUEST_FILENAME} !-d [NC] | |
# RewriteRule ^(.+)/$ /$1 [NC,R=301] | |
# SLASHES: Add a trailing slash to paths without an extension | |
# ------------------------------ | |
# RewriteCond %{REQUEST_METHOD} !=POST [NC] | |
# RewriteCond %{REQUEST_URI} /$ [NC] | |
# RewriteCond %{REQUEST_FILENAME} !-f [NC] | |
# RewriteCond %{REQUEST_FILENAME} !-d [NC] | |
# RewriteRule ^(.+[^/])$ /$1/ [NC,R=301] | |
# SSL: Entire Site | |
# ------------------------------ | |
# RewriteCond %{ENV:HTTPS} !on [NC] | |
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301] | |
# SSL: Specific sections | |
# ------------------------------ | |
# RewriteCond %{ENV:HTTPS} !on [NC] | |
# RewriteCond $1 ^(member|account|checkout|system) [NC] | |
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301] | |
# INDEX: Remove index.php | |
# Uses the "exclude method" | |
# http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Exclude_List_Method | |
# ------------------------------ | |
# Exclude root files | |
# RewriteCond $1 !^(favicon\.ico|index\.php|path\.php|php\.ini|cp.php) [NC] | |
# Exclude EE folders | |
# RewriteCond $1 !^(system|images|themes)/ [NC] | |
# Exclude 3rd party folders | |
# RewriteCond $1 !^(css|js|assets)/ [NC] | |
# RewriteCond %{REQUEST_FILENAME} !-f [NC] | |
# RewriteCond %{REQUEST_FILENAME} !-d [NC] | |
# Remove index.php | |
# RewriteRule ^(.*)$ /index.php/$1 [NC,R=301,L] | |
# INDEX: Standard ExpressionEngine Rewrite | |
# ------------------------------ | |
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC] | |
RewriteCond %{REQUEST_FILENAME} !-f [NC] | |
RewriteCond %{REQUEST_FILENAME} !-d [NC] | |
RewriteRule ^(.*)$ /index.php/$1 [NC,R=301,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment