Lyxen att manipulera statusmeddelande som error 404 gäller bara de få utvalda som har tillgång
till en egen webserver. Förändringarna göres alltså på servern och har du inte denna access så
är nog resten av sidan ganska ointressant.
Här följer några tips och varningar till hur man editerar de inbyggda statusmeddelande som visas
av Internet Information server 6...
Varför existerar dessa felkoder?
Webserven skickar alltid med ett svar i sin HTTP header. I svaret så ingår en status kod. Status 200 betyder att allt
är OK. När något felaktigt inträffas så skickas förutom status kod till klienten även ett felmeddelande. Detta felmeddelande
går att editera. Det kommer vi till senare. Det finns fem klasser av statuskoder.
Alla statuskoder som börjar på 1xx representerar information.
Alla statuskoder som börjar på 2xx representerar att något gått bra.
Alla statuskoder som börjar på 3xx representerar forwardering eller hänvisning.
Alla statuskoder som börjar på 4xx representerar klient fel
Alla statuskoder som börjar på 5xx representerar server fel.
Den absolut mest kända statuskoden är error 404, som betyder att sidan inte har hittats på angiven address.
I och med att statuskoden är så inarbetad som en felkod så kan jag, förvirrande, använda båda begreppen nedan.
Bild på ett vanligt, icke editerat, 404 meddelande:
Var finns mallen för dessa felsidor?
På en defaultinstallerad Internet information server så hittar du felmeddelandesidorna i följande katalog:
C:\WINDOWS\Help\iisHelp\common

Felmeddelandefilerna är skapade i html format och är därmed väldigt lätta att redigera.
Vad betyder dessa felkoder?
Innan man börjar redigera filerna så är det bra att veta i vilka sammanhang som dessa statuskoder returneras till användaren.
Här kommer en sammanställning av olika statuskoder som IIS kan returnera:
HTTP relaterade felkoder...
1xx - Informational
These status codes indicate a provisional response. The client should be prepared to receive one or more 1xx responses before receiving a regular response.
- 100 - Continue.
- 101 - Switching protocols.
2xx - Success
3xx - Redirection
The client browser must take more action to fulfill the request. For example, the browser may have to request a different page on the server or repeat the request by
using a proxy server.
- 301 - Moved Permanently
- 302 - Object moved.
- 304 - Not modified.
- 307 - Temporary redirect.
4xx - Client Error
An error occurs, and the client appears to be at fault. For example, the client may request a page that does not exist, or the client may not provide
valid authentication information.
- 400 - Bad request.
- 401 - Access denied. IIS defines a number of different 401 errors that indicate a more specific cause of the error. These specific error codes
are displayed in the browser but are not displayed in the IIS log:
- 401.1 - Logon failed.
- 401.2 - Logon failed due to server configuration.
- 401.3 - Unauthorized due to ACL on resource.
- 401.4 - Authorization failed by filter.
- 401.5 - Authorization failed by ISAPI/CGI application.
- 401.7 - Access denied by URL authorization policy on the Web server. This error code is specific to IIS 6.0.
- 403 - Forbidden. IIS defines a number of different 403 errors that indicate a more specific cause of the error:
- 403.1 - Execute access forbidden.
- 403.2 - Read access forbidden.
- 403.3 - Write access forbidden.
- 403.4 - SSL required.
- 403.5 - SSL 128 required.
- 403.6 - IP address rejected.
- 403.7 - Client certificate required.
- 403.8 - Site access denied.
- 403.9 - Too many users.
- 403.10 - Invalid configuration.
- 403.11 - Password change.
- 403.12 - Mapper denied access.
- 403.13 - Client certificate revoked.
- 403.14 - Directory listing denied.
- 403.15 - Client Access Licenses exceeded.
- 403.16 - Client certificate is untrusted or invalid.
- 403.17 - Client certificate has expired or is not yet valid.
- 403.18 - Cannot execute requested URL in the current application pool. This error code is specific to IIS 6.0.
- 403.19 - Cannot execute CGIs for the client in this application pool. This error code is specific to IIS 6.0.
- 403.20 - Passport logon failed. This error code is specific to IIS 6.0.
- 404 - Not found.
- 404.0 - (None) File or directory not found.
- 404.1 - Web site not accessible on the requested port.
- 404.2 - Web service extension lockdown policy prevents this request.
- 404.3 - MIME map policy prevents this request.
- 405 - HTTP verb used to access this page is not allowed (method not allowed.)
- 406 - Client browser does not accept the MIME type of the requested page.
- 407 - Proxy authentication required.
- 412 - Precondition failed.
- 413 - Request entity too large.
- 414 - Request-URI too long.
- 415 - Unsupported media type.
- 416 - Requested range not satisfiable.
- 417 - Execution failed.
- 423 - Locked error.
5xx - Server Error
The server cannot complete the request because it encounters an error.
- 500 - Internal server error.
- 500.12 - Application is busy restarting on the Web server.
- 500.13 - Web server is too busy.
- 500.15 - Direct requests for Global.asa are not allowed.
- 500.16 - UNC authorization credentials incorrect. This error code is specific to IIS 6.0.
- 500.18 - URL authorization store cannot be opened. This error code is specific to IIS 6.0.
- 500.100 - Internal ASP error.
- 501 - Header values specify a configuration that is not implemented.
- 502 - Web server received an invalid response while acting as a gateway or proxy.
- 502.1 - CGI application timeout.
- 502.2 - Error in CGI application.
- 503 - Service unavailable. This error code is specific to IIS 6.0.
- 504 - Gateway timeout.
- 505 - HTTP version not supported.
Common HTTP Status Codes and Their Causes
- 200 - Success. This status code indicates that IIS has successfully processed the request.
- 304 - Not Modified. The client requests a document that is already in its cache and the document has not been modified since it was cached.
The client uses the cached copy of the document, instead of downloading it from the server.
- 401.1 - Logon failed. The logon attempt is unsuccessful, probably because of a user name or password that is not valid.
- 401.3 - Unauthorized due to ACL on resource. This indicates a problem with NTFS permissions. This error may occur even if the permissions are
correct for the file that you are trying to access. For example, you see this error if the IUSR account does not have access to
the C:\Winnt\System32\Inetsrv directory. For additional information about how to resolve this problem, click the following article number
to view the article in the Microsoft Knowledge Base:
187506 (http://support.microsoft.com/kb/187506/) INFO: Basic NTFS permissions for IIS 4.0
- 403.1 - Execute access forbidden. The following are two common causes of this error message:
a) You do not have enough Execute permissions.
For example, you may receive this error message if you try to access an ASP page in a directory where permissions are set to None, or you try to
execute a CGI script in a directory with Scripts Only permissions. To modify the Execute permissions, right-click the directory in the Microsoft
Management Console (MMC), click Properties, click the Directory tab, and make sure that the Execute Permissions setting is appropriate for the
content that you are trying to access.
b) The script mapping for the file type that you are trying to execute is not set up to recognize the verb that you are using (for example,
GET or POST). To verify this, right-click the directory in the MMC, click Properties, click the Directory tab, click Configuration, and verify
that the script mapping for the appropriate file type is set up to allow the verb that you are using.
- 403.2 - Read access forbidden. Verify that you have set up IIS to allow Read access to the directory. Also, if you are using a default document,
verify that the document exists. For additional information about how to resolve this problem, click the article number below to view the article
in the Microsoft Knowledge Base:
247677 (http://support.microsoft.com/kb/247677/EN-US/) Error Message: 403.2 Forbidden: Read Access Forbidden
- 403.3 - Write access forbidden. Verify that the IIS permissions and the NTFS permissions are set up to grant Write access to the directory.For
additional information about how to resolve this problem, click the article number below to view the article in the Microsoft Knowledge Base:
248072 (http://support.microsoft.com/kb/248072/EN-US/) Error Message: 403.3 Forbidden: Write Access Forbidden
- 403.4 - SSL required. Disable the Require secure channel option, or use HTTPS instead of HTTP to access the page. If you receive this error for
a Web site that does not have a certificate installed, click the article number below to view the article in the Microsoft Knowledge Base:
224389 (http://support.microsoft.com/kb/224389/EN-US/) Err Msg: HTTP Error 403, 403.4, 403.5 Forbidden: SSL Required
- 403.5 - SSL 128 required. Disable the Require 128-bit encryption option, or use a browser that supports 128-bit encryption to view the page.
If you receive this error for a Web site that does not have a certificate installed, click the article number below to view the article in the Microsoft Knowledge Base:
224389 (http://support.microsoft.com/kb/224389/EN-US/) Err Msg: HTTP Error 403, 403.4, 403.5 Forbidden: SSL Required
- 403.6 - IP address rejected. You have configured your server to deny access to your current IP address. For additional information about how
to resolve this problem, click the article number below to view the article in the Microsoft Knowledge Base:
248043 (http://support.microsoft.com/kb/248043/EN-US/) Error Message: 403.6 - Forbidden: IP Address Rejected
- 403.7 - Client certificate required. You have configured your server to require a certificate for client authentication, but you do not have
a valid client certificate installed. For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
190004 (http://support.microsoft.com/kb/190004/EN-US/) Error 403.7 or 'Connection to Server Could Not Be Established'
186812 (http://support.microsoft.com/kb/186812/EN-US/) PRB: Error Message: 403.7 Forbidden: Client Certificate Required
- 403.8 - Site access denied. You have set up a domain name restriction for the domain that you are using to access your server.For additional
information about how to resolve this problem, click the article number below to view the article in the Microsoft Knowledge Base:
248032 (http://support.microsoft.com/kb/248032/EN-US/) Error Message: Forbidden: Site Access Denied 403.8
- 403.9 - Too many users. The number of users who are connected to the server exceeds the connection limit that you have set. For additional
information about how to change this limit, click the article number below to view the article in the Microsoft Knowledge Base:
248074 (http://support.microsoft.com/kb/248074/EN-US/) Error Message: Access Forbidden: Too Many Users Are Connected 403.9
NOTE: Microsoft Windows 2000 Professional and Microsoft Windows XP Professional automatically impose a 10-connection limit on IIS. You cannot change this limit.
- 403.12 - Mapper denied access. The page that you want to access requires a client certificate, but the user ID that is mapped to your
client certificate has been denied access to the file. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
248075 (http://support.microsoft.com/kb/248075/EN-US/) Error: HTTP 403.12 - Access Forbidden: Mapper Denied Access
- 404 - Not found. This error may occur if the file that you are trying to access has been moved or deleted. It can also occur if you
try to access a file that has a restricted file name extension after you install the URLScan tool. In this case, you see "Rejected by
URLScan" in the log file entry for that request.
- 500 - Internal server error. You see this error message for a wide variety of server-side errors. Your event viewer logs may contain
more information about why this error occurs. Additionally, you can disable friendly HTTP error messages to receive a detailed description
of the error. For additional information about how to disable friendly HTTP error messages, click the article number below to view the
article in the Microsoft Knowledge Base:
294807 (http://support.microsoft.com/kb/294807/EN-US/) HOWTO: Disable Internet Explorer 5 'Show Friendly HTTP Error Messages' Feature on the Server Side
- 500.12 - Application restarting. This indicates that you tried to load an ASP page while IIS was in the process of restarting the application.
This message should disappear when you refresh the page. If you refresh the page and the message appears again, it may be caused by antivirus
software that is scanning your Global.asa file. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
248013 (http://support.microsoft.com/kb/248013/EN-US/) Err Msg: HTTP Error 500-12 Application Restarting
- 500-100.ASP - ASP error. You receive this error message when you try to load an ASP page that has errors in the code. To obtain more
specific information about the error, disable friendly HTTP error messages. By default, this error is only enabled on the default Web
site.For additional information about how to see this error on non-default Web sites, click the article number below to view the
article in the Microsoft Knowledge Base:
261200 (http://support.microsoft.com/kb/261200/EN-US/) HTTP 500 Error Message Displays Instead of ASP Error Message from 500-100.asp
- 502 - Bad gateway. You receive this error message when you try to run a CGI script that does not return a valid set of HTTP headers.
Jag har markerat de statuskoder som är vanligast. Statuskod 200 får du varje gång du besöker en websida om den laddas utan problem. Felkod 404 är du
nog van vid, den får man om man skriver en adress som är felaktig.
Anledningen till att jag tar med statuskod 301 är att den är viktig att använda om du vill sökmotoroptimera din website. För att underlätta för google
& CO så bör du skapa en sida som returnerar statuskod 301 samt en hänvisning till den nya adressen. Gör man inte det så kommer google att ta bort sida A
och sedan indexera om sida B vid tillfälle, förutsatt att det finns en länk till den sidan. Under tiden detta sker så finns risken att man tappar
plaseringar i den organiska listan.
Går det att editera alla statussidor?
Nej, det går inte att editera följande statussida: 400, 403.9, 411, 414, 500, 500.11, 500.14, 500.15, 501, 503, and 505.
Skapa en egen 404 sida.

Det går att styra vilken sida som ska visas när ett visst fel inträffar. Detta gör man i Internet Information Services (IIS) manager verktyget (se bild ovan).
Endera så editerar du existerande mall filer, och detta är absolut enklast för då fungerar även response.header returen till klienten med automatik (mer om det senare),
eller så pekar du ut en egen informationssida på din lokala website. Med denna metod är det mycket enkelt att skapa en egendesignad felkodssida som ger
besökaren möjlighet att söka sig vidare på din website trots att ingångssidan inte längre existerar.
Sökväg till egenskap felkodssida.
\errors\404.asp
Om du väljer URL (egen sida) som typ så måste sidan existera på din lokala website. Använd en sökväg relativ till din webroot.
Notera att default så ändrar du om felsidan för hela webservern för ett specifikt felmeddelande. Har du flera websiter på samma server så kan detta bli ett problem.
Detta går dock att råda bot på genom att kopiera hela felkodskatalogen (alternativt din enda felkodsfil) och lägga den under respektive webroot.
Öppna sedan upp IIS admin interfacet på webservern och mappa om filerna till den nya sökvägen.
- Open up MMC.
- Choose the web site, where you want to map custom error messages, by clicking on the site within the MMC tree.
- Right click and choose Properties from the drop down menu.
- From with the properties dialog choose the Custom Error tab.
- From the Error messages for HTTP errors list, choose the error you wish to map.
- Once the error is chosen, click on Edit Properties button near the bottom of the dialog.
- Within the Error mapping Properties dialog change the Message type to URL.
- In the URL text box type in the URL of the new custom error.
- Click on OK, then OK again to save the changes
Vanliga fel vid egendesignad felkodssida!
Varje gång någon använder en webläsare och försöker hämta en websida så svarar webservern med en status kod innan websidan laddas upp. Denna status kod
ligger i något som kallas response header.
Exempel på en HTTP header när du besöker en websida som existerar:
HTTP/1.1 200 OK
Content-Type: text/html
Connection: close
Exempel på en HTTP header när du besöker en websida som inte existerar:
HTTP/1.1 404 Not Found
Content-Type: text/html
Connection: close
Ett problem som uppstår om man ersätter den inbyggda felkodsidan i IIS är att man glömmer bort att felkodsidan måste returnera status koden som
motsvarar det felmeddelande man ersatt. Till exempel, har du ersatt felkodsidan 404 med din egna www.minSajt.se/error404.htm så måste även denna returnera
HTTP header 404 (sidan hittas ej). I och med att webservern är tillsagd att forwardera besökaren till www.minSajt.se/error404.htm och den sidan
faktiskt existerar så kommer HTTP header 200 (sidan funnen) returnerars. Detta innebär att sidor som har indexerats av en sökmotor tenderar till
att bli felaktiga och risken att ni glider ner i den organiska listan är stor.
Hur styr jag vilken response kod som ska visas?
I de flesta fall så räcker det med att lägga till en vbscript (ASP) kod överst på sidan.
Exempel på en korrekt 404:
<%@ Language=VBScript %>
<% Response.Status = "404 Not Found" %>
Exempel på hur man returnerar 401 (tillträde förbjudet) för en specifik dator.
<%
ip = request.ServerVariables("REMOTE_ADDR")
if ip <> "194.248.333.500" then
response.Status="401 Unauthorized"
response.Write(response.Status)
response.End
end if
%>
Exempel på 301 (permanent flyttad sida).
Om du har en populär websida med en hög page rank och en bra placering på Googles organiska lista, då är det
av intresse att denna page rank följer med om du flyttar din websida, eller byter namn på filen.
Detta går att göra genom att använda HTTP response 301 som betyder "sidan är permanent flyttad".
Om google hittar en sådan sida så ska google ändra i sitt register, ta bort den gamla sidan men behålla alla
indexerade keywords, page rank osv, och flytta dessa till den nya sidan.
<%@ Language=VBScript %>
<%
' Permanent redirection
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.somacon.com/"
Response.End
%>
Gul markering visar var du skriver addressen till den nya sidan.
Hur ser jag vilken HTTP header kod som returneras?
Rex Swain har skapat ett online verktyg som hittas
här.
Är den för teknisk för din smak så kan du ladda hem en plugin till Firefox som heter
Live HTTP headers
När Live HTTP headers är installerad så gör du så här:
1) Surfa till din website.
2) Skriv in en felaktig länk. Till exempel: http://mattiasNordin.Net/felaktigAddress.asp
Du kommer då till en egenskapad felsida
3) Högerklicka på sidan, välj sedan "Visa sidinfo".
4) Välj tab "Headers".
5) Se nedre delen, response headers.

Exempel på en felaktig 404 sida:

Notera att sidan returnerar kod "200 OK" trots att det är en "404" sida.
Dynamisk felkodssida (ASP)
Nedan ser ni en bild på min egen server response sida. Den spar alla besökstillfällen i en databas. På så sätt bra koll på
vilka sidor som användarna tror sig ska finnas på min website. Det märks även när jag har skapat sidor som innehåller en felaktig
länk till en bild och liknande. Ett bra sätt att se fel och trafikmönster. Du märker här om tex googles spindel varje dag försöker
besöka en sida som du raderat för ett år sedan. Om detta inträffar då vet du att du inte returnerar status 404 på ett korrekt sätt.
Jag har själv lärt mig den hårda vägen ;)
Det finns en hel del att tänka på när man gör sina customiserade 404 sidor. Jesper Tverskov har skrivit "User friendly 404 error messages
reconsidered". Läs den!

Sidan ovan är en hemmabyggd ASP sida som ersätter en del av serverns standardfelkodssidor. En förutsättning var att det gick att
plocka fram felkoden dynamiskt. Och det går...
Med ASP går det att hämta både serverns response kod etc... Här kommer ett exempel:
<%@ Language=VBScript %>
'===== VISA ERROR INFORMATIONEN =====
varErrorUserCameFrom = Request.Servervariables("HTTP_REFERER")
varErrorUserIp = Request.Servervariables("REMOTE_ADDR")
varErrorString = Request.ServerVariables("QUERY_STRING")
If (Len(varErrorString) > 4) Then
varErrorCode = left(varErrorString,3)
varErrorUserSearchedFor = Right(varErrorString,Len(varErrorString)-4)
End If
'SPARA TILLFÄLLET DÅ ICKEEXISTERANDE SIDA ACCESSADES...
sql = "INSERT INTO T_error_log "
sql = sql & "(error_code, error_date, server_url, by_ip, http_referer) "
sql = sql & "Values('" &varErrorCode &"',"
sql = sql & "#" &now() &"#,"
sql = sql & "'" &varErrorUserSearchedFor &"',"
sql = sql & "'" &varErrorUserIp &"',"
sql = sql & "'" &varErrorUserCameFrom &"')"
'response.write("INSERT: " &sql)
connect.execute(sql)
%>
Citat från Google
"
Remove an outdated link
Google updates its entire index automatically on a regular basis. When we crawl the web, we find new pages, discard dead links,
and update links automatically. Links that are outdated now will most likely "fade out" of our index during our next crawl.
Note: If you believe your request is urgent and cannot wait until the next time Google crawls your site, use
our automatic URL removal system.
We'll accept your removal request only if the page returns a true 404 error via the http headers.
Please ensure that you return a true 404 error even if you choose to display a more user-friendly body of the HTML page for your
visitors. It won't help to return a page that says "File Not Found" if the http headers still return a status code of 200, or normal. "
Källor: Microsoft Article ID : 318380, IT-guru Mattias Nordin.