Any URL without a slash on the end will attempt to look in its parent directory for a file. So for these two URLs:
Code: Select all
domain.com/blog -> domain.com/blog
www.domain.com/blog -> domain.com/blog/
Code: Select all
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.domain.com/$1 [L,R]
RewriteRule ^blog$ blog/ [R]
The first line establishes a base directory. The next three redirect anything not starting with www to your fully qualified domain. And the last one adds the trailing slash.
In re-examining the documentation, I found that I was wrong: .htaccess files from higher-level directories are applied to the current directory. However, the lowest-level .htaccess overrules any higher-level .htaccess files. So, by putting that .htaccess in the document root directory, it will be applied to the blog/ directory as well. Therefore, we don't need (and don't want!) any www rewriting code in the /blog/.htaccess.
In that way, the /.htaccess takes care of these cases, too:
Code: Select all
domain.com/blog/ -> domain.com/blog/
www.domain.com/blog/ -> www.domain.com/blog/
You can also remove any slash-adding code from the /blog/.htaccess. All that should be necessary in there is the Serendipity redirects.