Forum Moderators: phranque
RewriteRule ^(.*[^/])$ /$1/ [L,R=301] RewriteEngine On
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !example.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301] RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)([^/])$ http://example.org/$1$2/ [R=301,L] RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9]+)/$ /$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([a-zA-Z0-9]+)
RewriteRule ^([a-zA-Z0-9]+)$ /%1/? [R=301,L] # Redirect adding trailing slash if missing
rewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
rewriteCond %{REQUEST_URI} !/somefolder$
rewriteRule ^(.*)$ http://%{HTTP_HOST}/support/$1/ [R=301,L]
# Redirect adding leading www to domain or any subdomain if missing
rewriteCond %{HTTP_HOST} !^www\.
rewriteCond %{REQUEST_URI} !/somefolder$
rewriteRule ^(.*)$ http://www.%{HTTP_HOST}/somefolder/$1 [R=301,L # Externally redirect to add missing trailing slash
RewriteRule ^([a-z_]+/([0-9]+/)*[0-9]+)$ http://www.example.com/$1/ [NC,R=301,L]
RewriteRule ^([a-z_]+)$ http://www.example.com/$1/ [NC,R=301,L] #add trailing slash to all the URL's
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.mysite.com/$1/ [L,R=301]
# Externally redirect to add missing trailing slash to requested URL-paths
# with no filetype (i.e. no period) in the final URL-path-part
RewriteRule ^(([^/]+/)*[^./]+)$ http://www.example.com/$1/ [R=301,L]
(([^/]+/)*[^./]+)$ ^(([^/]+/)*[^./]+)$
Pattern matches "one or more characters that is not a slash, followed by a slash; the preceding whole, repeating one or times if it appears, and is allowed to be missing" [i.e there is an optional "path" of any depth],
followed (after the final slash), "by one or more characters that are not a dot or slash" [i.e. the filename part of the URL has no "extension" on the end].
^(([^/]+/)*[^./]+)$
Pattern matches "one or more characters that is not a slash, followed by a slash; the preceding whole, repeating one or more times if it appears, and is allowed to be missing" [i.e there is an optional "path" of any depth],
followed (after the final slash), "by one or more characters that are not a dot or slash" [i.e. the filename part of the URL has no "extension" on the end].
repeating one or more times if it appears, and is allowed to be missing
There was a typo in my answer - a word missing (shown in bold).
I wrote a slightly wordier answer than was maybe required.
repeating one or more times if it appears, and is allowed to be missing
Yes, it simplifies to "zero or more times"; but I thought that might confuse.