Generate .htaccess with correct RewriteBase during installation

Here are two commits to generate the .htaccess file during the installation process.

Both up for discussion, but with special emphasis on the one cleaning trailing slashes. I couldn't find a place to sanitize the input from the installation process. If there's none, we should add one :-).

Note that htaccess-dist seems to be a leftover from an earlier piece of code in install.lib.php.
See write_courses_htaccess_file().

I didn't remove that code as I don't know where it comes from and it might be valuable although forgotten. 
After a grep -r, it seems to not be in use at all though (even the paths seem to be wrong).

I could follow up with a commit removing that if you want. But I guess it's better to ask around first.