Jump to content
xisto Community
Sign in to follow this  
chilipie

Custom Error Pages With .htaccess

Recommended Posts

So, who wants a site where instead of getting a default "Error 404" page in that ghastly font (Times) when you type the wrong address, you get a beautiful "Error 404" page that fits with your site's layout, colour and font scheme?

 

Well, if you do, I'm going to show you how to do it with .htaccess.

 

---

 

The most commonly occuring error pages are:

400 Bad Request

401 Authorization Required

403 Forbidden

404 Page Not Found

500 Internal Server Error

503 Service Unavailable

Open up a new file in your favourite text editor. Enter this:

ErrorDocument 400 /400.htmErrorDocument 401 /401.htmErrorDocument 403 /403.htmErrorDocument 404 /404.htmErrorDocument 500 /500.htmErrorDocument 501 /501.htm
Change "/400.htm" etc. to the server path (not URL) of the error document. Now, save this file as "htaccess.txt" and upload/FTP it to your webspace (if you want it to affect all of your directories, make sure it is in "public_html" or "www". Then rename it to ".htaccess" (remember the dot).

 

There you go! Type in an incorrect address at your domain, and it should come up with your custom error document.

Share this post


Link to post
Share on other sites

Very helpful, thanks a dozen for sharing this :)

Share this post


Link to post
Share on other sites

Would this be better than using the Custom Error Pages option in CPanel? is there any other benefits for either?

Share this post


Link to post
Share on other sites

Would this be better than using the Custom Error Pages option in CPanel? is there any other benefits for either?

<{POST_SNAPBACK}>


I don't know if there are any real benefits to it, but it is normally better to learn something this way rather than just using a system in cPanel. Also, if you ever have hosting where the only way of managing your files is through FTP, you can just use this method.

Share this post


Link to post
Share on other sites

A question here, is the .htaccess file supported by all servers? Do all servers recognise it? From your post, I presume that you still have to edit the style of the custom error document? Or do you just need to upload the .htaccess file only?Sorry, Im new to this htacess thing. Looks very useful to me.

Share this post


Link to post
Share on other sites

actually most free unix hosting support htaccess and some free hosting disable it for security reasons.about the error pages, you have to create a new one, your own customize error pages. if error occured it is redirected by the htaccess to the pages you've create not to the old boring error pages :)

Share this post


Link to post
Share on other sites

.htaccess can be used to stop hotlinking too. Hotlinking, also known as deep linking, occurs when one web site links directly to graphics files on another web site.


RewriteEngine onRewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite.com(/)?.*$     [NC]RewriteRule .*\.(gif|jpg|jpeg|bmp|zip)$ http://http://ww38.yoursite.com/leech.htm [R,NC]

The 2nd line checks the referer, the allowed pages to do hotlinking. You can duplicate the line and add another site.

The 3rd line are the protected extensions, and the page to redirect... like DIE LEECHERS!!!! or something more extreme :) .


Greets Deivid

Share this post


Link to post
Share on other sites

Can someone tell me whether anything is REQUIRED in the .htaccess file for Xisto? I think I accidentally deleted it and just wondering whether there is something essential inside the .htaccess file...Because all my php files are turning up blank... O_O

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.