Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Where is .htaccess file and best method to edit?

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)

Posted on Apr 26, 2012 1:09 PM

Reply
5 replies

Apr 27, 2012 7:43 AM in response to DOLAdmin

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.

Where is .htaccess file and best method to edit?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.