How to upgrade Apache 2.2.15 to 2.4.4 in CentOS?

Apache 1.3, default-deny policy, allow null basenames

  • I want to allow access to only certain file extensions (let's say just .phtml and .jpg) in a specific directory. I want to specify these in a default-to-deny way. In other words, I want to deny everything and then explicitly list the extensions to allow. Sounds easy. Here's the hard part: it HAS to also allow in the "empty file" that apache will silently point to index.phtml -- this happens if someone hits my web page like: "http://foo.com/directory/" with no file specified (mod_dir does this?). I've spent hours trying everything to get this to work and am coming to the conclusion it may be impossible due to the order in which apache processes modules. I've tried rewriterules, filesmatch, locationmatch, etc. A successful answer will satisfy all the following: 1. Provide an explicit way (apache directives) to accomplish the above. 2. Be tested and working, or known to work -- no "try this", "try that" ping-pong answers. 3. I will accept solutions that can be applied to httpd.conf or .htaccess files or both. However, any directives in .htaccess must NOT require the host name or directory name to be hardcoded. The .htaccess file must work without change on a dev and live box that utilize different hostnames and directories (or lack of). Hostnames and directories MAY be hardcoded in the httpd.conf file. The following will NOT be acceptable: 1. An answer of "can't be done", or an incomplete or non-working answer. 2. An answer of "upgrade to Apache 2.0" -- not an option WARNING: Myself and a very smart friend have spent hours trying to get this to work, to no avail. If you aren't sure you know the answer to this, don't bother trying -- apache will fight you at every turn and you'll waste your time. FYI, Here's what I at first tried and neatly summarizes what I want to achieve (it doesn't work): (in .htaccess) Order allow,deny <FilesMatch "(\.(phtml|jpg|png)|/)$"> Allow from all </FilesMatch>

  • Answer:

    Okay, at first I was stumped, but I seem to have a working solution. I have added the following to my <VirtualHost> directive for my website, and it has the desired effect: <Directory /home/www/docs/dylan.wibble.net/ga-test/> Order Deny,Allow Deny From All Allow From None <FilesMatch "\.(php|jpg|png)$"> Allow from All </FilesMatch> </Directory> <LocationMatch "/ga-test/$"> Order Deny,Allow Allow from All </LocationMatch> The directory has the following files: index.php index.php~ test.jpg test.png test.txt The following URLs are allowed: http://dylan.wibble.net/ga-test/ http://dylan.wibble.net/ga-test/index.php http://dylan.wibble.net/ga-test/test.jpg http://dylan.wibble.net/ga-test/test.png The following URLs are forbidden: http://dylan.wibble.net/ga-test/test.txt http://dylan.wibble.net/ga-test/index.php~ As the <LocationMatch> directive does not seem to be allowable in .htaccess, this will only work in httpd.conf or a <VirtualHost> directive. You wouldn't believe some of the ways I tried first, then this suddenly dawned upon me :) This was tested on Apache 1.3.27 running on a Debian GNU/Linux server. Information Sources: http://httpd.apache.org/docs/mod/directives.html Regards, sycophant-ga

tcordes-ga at Google Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.