5 Replies Latest reply: Apr 27, 2012 7:43 AM by Camelot
DOLAdmin Level 1 Level 1 (0 points)

I have to position some official "error pages" on our Lion Server's Apache web server in (as I understand it) the ".htaccess file" so the "Not Found" error message doesn’t display the Apache Version and ports information for 400, 404, 500, etc. errors.  Our Web administrator says he'll give me some temporary html files later to place into a directory I need to create called "errors" and to paste the following into the .htaccess file file:

 

# Copy and Paste this into your .htaccess

 

ErrorDocument 503 /errors/503.html

ErrorDocument 401 /errors/401.html

ErrorDocument 500 /errors/500.html

ErrorDocument 301 /errors/301.html

ErrorDocument 403 /errors/403.html

ErrorDocument 400 /errors/400.html

ErrorDocument 408 /errors/408.html

ErrorDocument 302 /errors/302.html

ErrorDocument 405 /errors/405.html

ErrorDocument 415 /errors/415.html

ErrorDocument 404 /errors/404.html

ErrorDocument 501 /errors/501.html

ErrorDocument 502 /errors/502.html

ErrorDocument 504 /errors/504.html

ErrorDocument 505 /errors/505.html

 

What's the path to the .htaccess file and can this be done easily throgh the standard Terminal editors? 


Mac Pro, Mac OS X (10.7.3)
  • 1. Re: Where is .htaccess file and best method to edit?
    leroydouglas Level 6 Level 6 (13,855 points)

    I just re read : "Lion Server"

     

    I'll let someone else answer your question more specifically.

  • 2. Re: Where is .htaccess file and best method to edit?
    Camelot Level 8 Level 8 (45,790 points)

    .htaccess files are ignored by default. Adding the file, via whatever method, won't have any effect.

     

    You'll also need to tell Apache to read .htaccess files and honor their content. Or add the directives to /etc/apache2/httpd.conf, or the site-specific configuration file for your site.

  • 3. Re: Where is .htaccess file and best method to edit?
    DOLAdmin Level 1 Level 1 (0 points)

    Thanks all the same leroydouglas

  • 4. Re: Where is .htaccess file and best method to edit?
    DOLAdmin Level 1 Level 1 (0 points)

    Camelot thanks again. 

     

    Apologies for struggling with your response.  If ".htaccess files are ignored by default" did you mean to say "You'll also need to tell Apache to read .htaccess files and honor their content"?

  • 5. Re: Where is .htaccess file and best method to edit?
    Camelot Level 8 Level 8 (45,790 points)

    Apologies for struggling with your response.  If ".htaccess files are ignored by default" did you mean to say "You'll also need to tell Apache to read .htaccess files and honor their content"?

    I kind of mean what I said. By default, out of the box, Apache ignores .htaccess files. It doesn't look for them, it doesn't process them. This is partly a security measure (.htaccess can do all kinds of funky things) and it's partly for performance (if it doesn't have to check for .htaccess files, things move quicker).

     

    If you want Apache to look for, and honor, .htacess files you need to tell it so.

     

    You do this by adding AllowOverride directives to the config files - any AllowOverride (other than 'none'') tells Apache to look for a .htaccess file.

    To add to the confusion, .htaccess commands fall into one of several categories, depending on what they do. You can either enable All categories, or enable/disable individual ones.

     

    This is all covered at length in the Apache .htaccess tutorial.

     

    Suffice to say, you'll need to do something like this in your site's (or server's) config::

     

    <Directory /path/to/your/documentroot>

     

    AllowOverride fileinfo

     

    </Directory>

     

    before your .htaccess file will have any effect on your server. The 'FileInfo' override allows .htaccess files in the directory tree to redirect a request to a different file path.