Requirements
Make sure your system meets the minimum requirements:
- ExpressionEngine 2
- Morphine CP theme addon
- PHP 5.1.6+ (Engine Hosting: OK)
- A modern browser: Firefox, Safari, Google Chrome or IE8+
Installation
- Download the latest version of NSM .htaccess Generator and extract the .zip to your desktop.
- Copy
system/expressionengine/third_party/nsm_htaccess_generatortosystem/expressionengine/third_party - Install Morphine CP theme addon
Activation
- Log into your control panel
- Browse to
Addons → Extensions - Enable the extension
Configuration
Extension settings
.htaccess Configuration
NSM .htaccess generator has two config settings.
.htaccess Path
/yoursite.com/web/content/.htaccess
A full server path to your .htaccess file. The file must exist and be writable.
.htaccess Template
# secure .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# EE 404 page for missing pages
ErrorDocument 404 /index.php/{ee:404}
# Simple 404 for missing files
<FilesMatch "(\.jpe?g|gif|png|bmp|css|js|flv)$">
ErrorDocument 404 "File Not Found"
</FilesMatch>
RewriteEngine On
RewriteBase /
# remove the www
# RewriteCond %{HTTP_HOST} ^www.yoursite.com
# RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
# Remove the trailing slash to paths without an extension
RewriteCond %{REQUEST_URI} /$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Remove index.php
# Uses the "include method"
# http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method
RewriteCond %{QUERY_STRING} !^(ACT=.*)$ [NC]
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/({ee:template_groups}{ee:pages}members|P[0-9]{2,8}) [NC]
RewriteRule (.*) /index.php/$1 [L]
When an entry or template is saved or updated the .htaccess template will be added to the .htaccess file. If the template has already been rendered it will be updated.
During the update process the following tags will be replaced in the .htaccess template:
- {ee:404}: Replaced with the sites 404 path ie: site/404
- {ee:template_groups}: Replaced with a pipe delimited list of template groups followed by a pipe "|". eg:
news|site|videos| - {ee:pages}: Replaced with a pipe delimited list of page roots (the first segment of the URL) followed by a pipe "|". eg:
contact-us|privacy-poilcy|terms|
The default template includes rules that implement the "include list method".