1

I have two CentOS boxes running Apache. One is my dev environment and the other is my production environment. I am looking at using Gulp in a process of pushing from my dev server to my production server via Git, but have different configuration requirements in my .htaccess file based on the environment.

What I'd like to do is have some type of central configuration file that allows me to update these configurations and then when I push to dev it sets certain aspects of the .htaccess file to the dev settings and when pushed to production it uses my production settings.

(I guess the other option is to have a dev.htaccess and prod.htaccess and have Gulp just rename the appropriate file to .htaccess according to which environment it is pushing to. I'd like to avoid having to maintain multiple .htaccess files though.)

1 Answer 1

1

IMHO you should maintain your server configuration separate from your code.

Configuration management tooling should easily allow you to maintain the correct configuration for a specific environment and your code ought to be able to run in any correctly configured environment.

So don't include your .htaccess file in your deployment and preferably: do not use .htaccess files at all!

As quoted from from the manual on .htaccess files:

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block in the main Apache configuration file(s), as it will have the same effect with better performance.

1
  • Sure, in an ideal world where I was building everything from scratch this would be great. But we are in the real world where we are building on top of multiple pre-built stacks and this just isn't an option.
    – Jeremy H.
    Oct 13, 2015 at 18:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .