Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
    </Files>
.....
</Directory>

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

share|improve this question
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.