Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 am trying to use rsync to replicate all the files from one web server to another server that could act as a backup if the first one went down. The problem I am having is that the .htaccess file requires the AuthUserFile to have the fully quallified path to the .htpasswd file and I cannot make the paths the same on the two machines.

Does anyone know how I might use the same .htaccess file on two different servers?

Thanks for any help that can be provided.

share|improve this question
up vote 4 down vote accepted

Yet another way to do it is to specify an exclude pattern, so that rsync won't touch the .htaccess file.

rsync --exclude-from=/home/user/.rsync/exclude.pat ...

And the exclude.pat file should be in this format:

- /.htaccess
- .htaccess

The first entry will tell rsync to exclude only the root .htaccess, the second one - to exclude all .htaccess files within the synchronisation tree. You can look it up in the rsync manual.

share|improve this answer

One option is to use a database for your authdb instead of a file via e.g. mod_auth_mysql. This completely mitigates the need to specify any sort of a filename.

share|improve this answer
That sounds like the correct way to do it. I was hoping for less involved solution but that definitely seems like the proper answer. – stephenmm Jun 7 '10 at 2:44
As an added bonus, you will also be able to edit the authdb over the web easily enough. – Ignacio Vazquez-Abrams Jun 7 '10 at 2:51

If you have shell access i think a simple sed/awk command after the rsync operation to change the path.


sed s/tommy/joe/ < .htaccessSiteA > .htaccess

for more information, man sed or

share|improve this answer

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.