404 Custom Error Page Htaccess
Contents |
- sql HTML & Graphics Tutorials getting started backgrounds buttons browser specific colors forms frames html 4.01 tags html 4.01 ref image maps tables web graphics Beyond HTML asp cascading style sheets css keyword ref cgi scripting developer research center dhtml/layers dot net java applets javascript javascript frameworks javascript htaccess redirect 404 to custom page keyword ref javascript script tips mobile web development open source cms php security SEO vb script
Set 404 Error Page In Htaccess
keyword ref webmaster tips webmaster projects webmaster toolbox video xml general reference pieces the master list Need Help? discussion boards mentors Post a comment Email how to make custom 404 page Article Print Article Share Articles Reddit Facebook Twitter del.icio.us Digg Slashdot DZone StumbleUpon FriendFeed Furl Newsvine Google LinkedIn MySpace Technorati YahooBuzz How Do I Create a Custom 404 Error Page? By Joe Burns Tweet Ah, the aggravating 404 error page. custom 404 page template You've seen it. There you are, surfing in your favorite search engine when you happen upon just the thing you're looking for. You click: (***Raspberry Sound Effect***) Nothing but a white page with the words "404 Error" and some other techie-sounding speak beneath. What's even more cheesy about the error code is that it really doesn't tell you what the problem is. Basically you've been informed that the server cannot find what you want. It doesn't tell you why, how to fix
Custom 404 Page Examples
it, or where to go from that point. You really don't have much choice but to hit your BACK button, call the computer a dirty name, and try again. But then you see it--a server that's set up with its own special 404 error page that politely apologizes and offers you links to e-mail site administrators and maybe a site search engine. Now that's class! So I waltzed into the office of the Webmaster at work and asked how it was done. I was stunned at how easy it is to set up. Want one of your own? Here's how. You'd Best Ask First I'm going to offer you a very basic fix to this problem, but you'd best ask your system people if they want you doing this first. Better yet, ask them if you might mess things up by doing this. Your .htaccess File This is the file that will do the trick for you. You should already have one waiting inside of your Web site directory. If you don't, then you'll need to create it. FTP into your server so you're looking at the top level directory where you store your Web page files. This should be the directory that contains your home page document. Look for the .htaccess file there. Again, if you don't find it (it should be one of the very first files), then you'll need to create it. Please notice the dot (.) starting it off. H
you click a link and encounter a "404 File Not Found" error? Do you: Click on the BACK button of your browser and go somewhere else? Try to back up one directory in the URL (ie, web address) and try how to create 404 error page in html again? Write to the webmaster of the site and the referring site to inform them of the custom 404 page apache situation? If you are like most people, you'll simply click on the BACK button and try another place. The majority of people don't even know that
How To Create 404 Error Page In Php
there are any other alternatives. You thus need to do something so that you do not lose this group of people who come to your site by following an old link or by typing your URL incorrectly. Requirements for Customizing the 404 http://www.htmlgoodies.com/beyond/reference/article.php/3472591/How-Do-I-Create-a-Custom-404-Error-Page.htm File Not Found Page It is not possible to customize your 404 error page if your web host has not enabled this facility for your website. For example, at the time of this writing, if you host at free web hosts like Geocities or Tripod, you will not be able to customize your 404 Error Page. Commercial web hosts, on the other hand, usually provide this facility. If your web host supports a way to customise your 404 file, you will usually find mention of http://www.thesitewizard.com/archive/custom404.shtml it somewhere in their documentation (or advertisements). In fact, if they mention somewhere that you can customize a file named ".htaccess", it probably means that you can also customize your 404 File Not Found error page. The .htaccess file is what Apache web servers use to allow you to fine-tune your web server configurations at a directory level. Other types of web servers handle the customization of 404 error pages differently. (A web server, in this context, is the software that runs on your web host's computer. It is the program that "serves" your web pages to your visitors.) Step One: Creating/Modifying the .htaccess File This step may not be necessary in all situations. Some web hosts already configure their web server so that it will look for a specific file in your web directory when a certain document cannot be found. If so, simply skip this step. If your web server is not an Apache web server, you will have to find out from your web host what you need to do to enable the server to serve your customized file when a file cannot be found. This article only applies to websites that are hosted on Apache web servers. Otherwise, the first thing you need to do is to add the following line to a file named .htaccess (note the preceding period). In most instances, no such file will exist, and you can simply create one with a text editor (such as Notepad on Windows). Incidentally, if you are using Notepad o
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and http://stackoverflow.com/questions/19962787/rewrite-url-after-redirecting-404-error-htaccess policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only error page takes a minute: Sign up Rewrite URL after redirecting 404 error htaccess up vote 10 down vote favorite 11 So I know this may seem a little strange but I for sake of consistency, I would like all my urls to appear in this form: http://domain.com/page/ So far I have gotten the regular pages working but I cannot seem to get custom 404 page the error pages working properly. If the user visits a page or directory that does not exist, I would like the browser to hard redirect to: http://domain.com/404/ This directory, however, will not actually exist. The real location of the error page will be under /pages/errors/404.php Also, although I do not need an exact answer for all the various errors (400, 401, 403, 404, 500), I will be applying whatever method is given to redirect all of these to their "proper" URL's (eg. http://domain.com/400/ http://domain.com/500/ etc.) Any ideas? .htaccess redirect url-rewriting rewrite custom-error-pages share|improve this question asked Nov 13 '13 at 19:36 Leinardo Smtih 2521313 add a comment| 4 Answers 4 active oldest votes up vote 16 down vote accepted Try this in your .htaccess: .htaccess ErrorDocument 404 http://example.com/404/ ErrorDocument 500 http://example.com/500/ # or map them to one error document: # ErrorDocument 404 /pages/errors/error_redirect.php # ErrorDocument 500 /pages/errors/error_redirect.php RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/404/$ RewriteRule ^(.*)$ /pages/errors/404.php [L] RewriteCond %{REQUEST_URI} ^/500/$ RewriteRule ^(.*)$ /pages/errors/500.php [L] # or map them to one error document: #RewriteCond %{REQUEST_URI} ^/404/$ [OR] #RewriteCond %{REQUEST_URI} ^/500