Htaccess guide & tricks
Alert! Connect with 10,000 Chating Online. Join Now 500, 403, 401, 404 Custom Error Pages | |
Custom error pages are used to prevent people from seing boring error message such as "Permission Denied" or "Page Cannot be Found"? when ever a page is not found on a server or a page is not accessible. It is also used to remove boring server 500 , 404, 401, 403 error messages. You can liven up the error messages by creating custom error pages for each type of error you anticipate your visitors will encounter: A 404 error message is the standard HTTP standard response code which is returned when the visitor cannot communicate with the server. This is a very common error on the web and it occurs when you are trying to visit a page which has either been deleted or has been moved somewhere else. For example, if you change the structure of your website and move a certain directory to a different part of your site, anyone trying to visit the old page url will get a 404 error message.
When you encounter A 404 error message the server will return page not found and additional information like this : The requested URL /index.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7a mod_bwlimited/1.4 PHP/5.2.6 Server at yourwebsite.com Port 80. This is annoying to a visitor if the cannot see what they are looking for. They will try to see other part of your site to see if the can locate the information. So it is good to create a custom 404 page that will guide the visitor and redirect traffic from incorrect urls. So all you need to do is to create a custom 404 page like this http://www.yoursite.com/404.php which will have information like So all you need to do is to create a custom 404 page like this http://www.yoursite.com/404.php which will have information like : It appears you are looking for something which isn’t there. Either you have entered an incorrect URL or we have messed up. Why not visit our home page or alternatively, search for what you are looking for in the search box below. Whilst a 404 error page does not send the visitor to the exact page they want, it does point them in the right direction and it means they are more likely to stay on your site. Once you have your 404 page setup, all you need to do is send visitors to incorrect url’s to this page. To do this just add the following line to your .htaccess file : ErrorDocument 404 /404.php 401, 403, 500 error messagesWe have other errors on the server like 401, 403, 500 error messages etc. each of this error can be handled by creating custom page like this ones below in your htaccess file. Just create this pages on your server and add this line to your htaccess file. ErrorDocument 401 /admin/authorization.htm ErrorDocument 403 /password/forbidden.htm ErrorDocument 500 /password/forbidden.htm
Custom error page is easy to create, to create custom error pages, replace the error code next to ErrorDocument to the appropriate error code, and change the URL of the page that you want the user to see when there is error. |
Change Non WWW URLs to WWW URLs Turning On Compression using GZIP SEO 301 Redirect Change the Default Directory Page/index file How to Stop Directory Listing How to stop someone looking at your htaccess file Password Protect a Directory Control access at files & directory level Modifying the Environment Variable Implementing server Caching Scheme with .htaccess Redirect browser to https (ssl) Rewrite URLs using htacccess Adding new MIME types) Specify Upload file limit for PHP in htaccess Disallow Script Execution Change Charset and Language headers Set Timezone of the Server (GMT) Force "File Save As" Prompt and File download Protecting a single file Set Cookie using htaccess Send Custom Headers Blocking request based on User-Agent Header Disable caching for certain file type Hotlinking protection with .htaccess Prevent hacks Disable directory browsing Rename .htaccess files to another filename Change default Index page Block unwanted visitor based on referring domain Secure directories by disabling execution of scripts |