Forum Moderators: phranque
RewriteEngine On
# Remove Index.php from URLs
RewriteCond $1 !(^index\.php|(\.(gif|jpe?g|png|css|js)))$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# Force www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This means that example.com/index.php/about/ becomes example.com/about/ which is much nicer.
RewriteEngine On
# Add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]
# Remove Index.php
RewriteCond $1 !(^index\.php|(\.(gif|jpe?g|png|css|js)))$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteEngine On
# Add trailing slash to URLs if it is not there
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ http://www.mywebsite.com/$1/ [R=301,L]
# Remove index.php from URLs
RewriteCond $1 !(^index\.php|(\.(gif|jpe?g|png|css|js)))$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteEngine On
# Force www in the URLs
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# Add trailing slash to URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ http://www.mywebsite.com/$1/ [R=301,L]
# Remove index.php from URLs
RewriteCond $1 !(^index\.php|(\.(gif|jpe?g|png|css|js)))$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# Externally redirect to add missing trailing slash to URLs with no filetype
RewriteCond $1 !(\.[a-z0-9]{1,5}|/)$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1/ [R=301,L]
# Externally redirect non-blank non-canonical hostname request to canonical hostname
# (if not already done by the above rule)
RewriteCond %{HTTP_HOST} !^(www\.mysite.com)?$
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
# Rewrite all requests which do not resolve to existing files to the CMS script, except
# for image, css, and JS file requests, none of which need to be handled by the CMS,
# and requests for index.php itself (to avoid a wasteful second-pass exists check).
RewriteCond $1 !(^index\.php|\.(gif|jpe?g|png|css|js))$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^(.*)$ /index.php/$1 [L] RewriteRule (.*) /index.php?param=$1 [L]