1

I want to change the RewriteBase depending on the domain. In a perfect world I would do this in the .htaccess itself. But my understanding is that this is impossible.

The problem is that I have a local git repo and a repo on our dev server. The repo on the dev server is within a subfolder (example.com/mysite) while localy its just example.lo.

So on the server I have to set the RewriteBase to /mysite

My question then is, what is the best sollution to solve this? We can use git hooks to trigger a bash script on the bare server repo.

Will it work to add the .htaccess to the .gitignore when the repo is --bare and using this post receive hook?:

#!/bin/sh
GIT_WORK_TREE=/Users/Admin/Sites/mysite git checkout -f

Drop in a comment if Im unclear about anything. All help is appreciated!

Spoeken
  • 2,549
  • 2
  • 28
  • 40

1 Answers1

1

That kind of post-receive hook can work, but you might end up with a Not a git repository '.'” error message.

See "Git checkout in post-receive hook: “Not a git repository '.'": you should set GIT_DIR too, not just GIT_WORK_TREE.

The question is if it will delete the .htaccess file when it checks out the files, when the .htaccess is in the .gitignore file

No you won't delete it.

If you still need to update its value (depending on the domain) and version it with git, use a content filter: see "What's the easiest way to deal with project configuration files?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The hook works. That I know. The question is if it will delete the .htaccess file when it checks out the files, when the .htaccess is in the .gitignore file? And is there a better way to do this? One problem with this sollution is that you can never edit your .htaccess file and update it on the server through git. – Spoeken Dec 20 '12 at 11:39
  • 1
    @MathiasMadsenStav I have edited my answer to address your questions. – VonC Dec 20 '12 at 12:17