views:

26

answers:

1

Ok, here is my issue and the reason I want to split up the .htaccess file into two parts:

I have a local developing machine with windows as well as a test and a productive system running on the same machine on openSUSE. That causes me some trouble:

  • I use a htaccess auth mechanism which need an absolute AuthUserFile path
  • I use a rewrite condition for non www subdomains on the productive system
  • I use several caching techniques on the productive system I don't want to use on my local system
  • I have some kind of IP blacklist I update on my productive system

The whole system including the .htaccess is stored and updated with a SVN repository. So each change for the productive system I have to make after an update. So every new update is a merge which sometimes causes a conflict. If I revert a version of the .htaccess because of some errors in the .htaccess it causes in a lost of all the custom changes.

So my question is: Can I split a .htaccess file in several parts and include them into each other. or is it possible to have another kind of apache config file (like a httpd.conf). I also use Plesk to manage the domains and as I am not a linux expert I would prefer a solution without changing the Plesk configuration files of the domain.

+1  A: 

If you have complete control over both systems, use the Apache httpd.conf file. It can handle everything that .htaccess can and more, and is preferred above .htaccess for speed and security reasons.

If for some reason you need to divide the settings over multiple files (eg. some settings are common among the systems and should be under version control, others not), you can use include directives in the httpd.conf file like S.Lott says.

If you don't have control over httpd.conf in both systems, I don't know whether include directives are supported there; however you could try to use conditional blocks in your htaccess file as explained here.

littlegreen
I would go with the conditionals. That's kind of what I currently do. However, blacklisting IP addresses in your .htaccess file is a bit odd and unwieldy, no Kau-boy?
sims
If you have a httpd.conf in you htdocs folder, will it be used by apache automatically as a .htaccess or php.ini will usually be?
Kau-Boy
No, you will need root access to the server to edit the **server-wide** httpd.conf. If you only have access to your own htdocs folder, you cannot use httpd.conf at all, and you have to use htaccess. As said, I don't know whether include works in htaccess, but you can try to put everything in one file, and use two conditional blocks, one debug and one production that is chosen based on an environment variable or the such.
littlegreen