Forum Moderators: phranque
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
# ADD WWW
RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]
RewriteRule ^.*$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# ADD / FORWARD SLASH /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^.*$ %{REQUEST_URI}/ [R=301,L]
# REDIRECT TO INDEX EVERY TIME
RewriteRule ^([0-9a-zA-Z-]+)/?(([0-9a-zA-Z-]+)/)?$ /index.php?p=$1&l=$3 [L]
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI}\/%{HTTP_HOST}/www. ^/+(.+/)?[^.]*[^/]\(/)(([^.]{4,}|[^w.]?[^.][^w.]?[^.]?[^w.]?)..+/(www.)|.*)$ [OR,NC]
RewriteCond %{HTTP_HOST}/www. ^(/)?(#)?(/)?(([^.]{4,}|[^w.]?[^.][^w.]?[^.]?[^w.]?)..+/(www.))$ [NC]
RewriteRule ^ http://%6%{HTTP_HOST}%{REQUEST_URI}%2 [L,R=301]
# REDIRECT TO INDEX EVERY TIME
RewriteRule ^([0-9a-zA-Z-]+)/?(([0-9a-zA-Z-]+)/)?$ /index.php?p=$1&l=$3 [L]
[edited by: jdMorgan at 1:48 pm (utc) on May 7, 2010]
[edit reason] Tidied-up [/edit]
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#
# Define canonical hostname (add "www" if it is missing)
RewriteCond www.%{HTTP_HOST} ^(www\.)?(www\.[a-z-]+\.[a-z]{2,6})\.?(:[0-9]+)?$ [NC]
RewriteRule ^ - [E=MyHostName:%2]
#
# Externally redirect to add missing trailing slash to requested
# URLs containing no period in the final URL-path-part
RewriteRule ^(([^/]+/)*[^.]*[^./])$ http://%{ENV:MyHostName}/$1/ [R=301,L]
#
# Externally redirect to canonical "www" subdomains
RewriteCond %{HTTP_HOST} !^(www\.[a-z-]+\.[a-z]{2,6}\.?(:[0-9]+)?)?$ [NC]
RewriteRule ^(.*)$ http://%{ENV:MyHostName}/$1 [R=301,L]
#
# Internally rewrite all "page" requests to /index.php
RewriteRule ^([0-9a-z\-]+)(/([0-9a-z\-]+))?/$ /index.php?p=$1&l=$3 [NC,L]
[edited by: jdMorgan at 1:48 pm (utc) on May 7, 2010]
[edit reason] Tidied-up. [/edit]