Forum Moderators: phranque
[edited by: jdMorgan at 10:22 pm (utc) on Feb 16, 2010]
# [R] = Do a redirect with new URL (rather than hiding the new URL)
RewriteEngine on
#
# Redirect specific URLs
RewriteRule ^old\.html$ http://www.example.com/new/page [R=301,L]
RewriteRule ^shorturl$ http://www.example.com/path/to/long/url/ [R=301,L]
#
# Redirect to add a trailing slash if the slash is missing, no filetype is appended
# to the URL-path, and the requested URL-path does not resolve to an existing file
RewriteCond $1 !^([^/]*/)*[^.]*\.[a-z0-9]+$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ http://www.example.com/$1/ [R=301,L]
#
# Redirect to force canonical "www" subdomain
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#
# Expression Engine Rewrite - with turbo boost(tm) by jdm@WebmasterWorld
RewriteCond $1 !^index\.php$
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]