I have this rewrite rule that turns foo.com/test (or foo.com/test/) into foo.com/test.txt:
RewriteRule ^test/?$ test.txt [NC,L]
It works pe
Add the trailing slash:
RewriteRule ^test2/?$ testdir/ [NC,L]
http://foo.com/testdir isn't a valid url to the directory, Apache looks for a file called testdir, and because testdir is actually a directory Apache tries to fix it by redirecting to testdir/ . So while your rewrite worked the subsequent missing slash error was fixed by redirecting to testdir/.
You may also need to add a base href tag to the head of your document or relative links will break:
<base href="/">