Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a htdocs directory where I am serving a few Microsoft Word documents. When someone is editing a document, the name of the document changes to look like something like this: "~$my_document.doc" and also .tmp files are created that represent edits of the document until the document is closed.

So, I want Apache to not serve these files until the user is finished editing them. So, I want to hide files ending with .tmp extension at the same time that I am hiding files that start with "~$" .

So, can anyone help me enhance this Apache directive to accomplish this?

<Directory "C:/Apache2.2/htdocs">
    <Files ~ "\.tmp$">
      Order allow,deny
      Deny from all

This is a regular expression trick that is beyond my ability right now.

share|improve this question
up vote 1 down vote accepted

I don't have a system to test, but I would suppose you need to do something like this.

This should match either any file name that starts with a ~$ followed by anything, and any files that end in .tmp.

<FilesMatch "(~\$.*|\.tmp)$"> ... </FilesMatch>
share|improve this answer
This worked great. Thanks! – djangofan Dec 20 '11 at 17:38

Do another <Files> block with the expression ^~\$.

Keep in mind that the original file doesn't disappear when the file's being edited - if that's a problem for what you're looking to do, then you'll need some more complex regex voodoo.

share|improve this answer
Thanks for the suggestion. I should have thought of that. – djangofan Dec 20 '11 at 17:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.