Please wait while we load your page...


HTACCESS Magic :: Page 2

Results 3 to 4 of 16

Custom Error Messages

You can create custom error messages instead of using the default and very ugly, plain jane Apache error messages. Much more professional. Here is the line(s) to add to your .htaccess file:

ErrorDocument XXX /XXX.html

You need to create the XXX.html pages in advance. They can be any files or file types, or you can just point to a directory. Replace XXX with server HTTP Status Code. Some example and common error codes:

401 Unauthorized
Similar to 403 Forbidden, but specifically for use when authentication is required, and has failed or has not yet been provided.

403 Forbidden
The request was a valid request, but the server is refusing to respond to it.

404 Not Found
The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.

500 Internal Server Error
Miscellaneous server error (usually better documented in the server error log).

Last Revised: 2015-08-31

Deny Visitors By IP Address Or Host

The Apache Allow and Deny directives let you allow and deny access based on the host name, or host address, of the machine requesting a document. The Order directive goes hand-in-hand with these two, and tells Apache in which order to apply the filters. These are very useful for blocking unwanted access, or to restrict access to certain sections of the website. For example:

order deny,allow
deny from
deny from 98.76.54.
deny from
allow from all

The above lines tell the Apache Web Server to block access from those with the IP address '', or those whose IP address starts as '98.76.54.', or whose IP address resolves to The second IP address is missing the fourth set of digits. This means any IP address which matches the firth three set of digits will be blocked. For example, '' and '' would both be blocked. You could also use deny from 98.76. or deny from 98., but these are less specific. Since you are throwing a larger net, you may block valid users. Be careful!

To setup blocking of all visitors except yourself (IP address

order deny,allow
deny from all
allow from

The above lines tell the Apache Web Server to block all visitors except those with the IP address '': replace '' with your own IP address. Typically you would use this to restrict access in admin areas to just you for security.

Blocked visitors will be shown a '403 Forbidden' error message. You can customize this error message by using the 'ErrorDocument' directive in the .htaccess file:

ErrorDocument 403 /error-403.html

All you have to do is to create and upload a error-403.html page to server root. Blocked users will be redirected to this page.

Last Revised: 2015-07-06

Live Chat Not Available