Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

sr.silva

Página 404

Recommended Posts

achei esse código na net....se interessar para alguem, depois avisa se realmente funciona!

 

<%OPTION EXPLICITresponse.status = "404 Not Found"' DESCRIPTION'' This script generates a 404 error page that displays a list of alternate' pages for the user to visit.  It works by matching word similarity by both' a character-similarity value as well as a soundex value.  Replace the HTML' at the top and bottom of the page with data appropriate for your site. If' you would like to see this script in action, visit' [url="http://www.cwolves.com/hme.asp"]http://www.cwolves.com/hme.asp[/url]'' INSTALLATION'' Installation requires administrative access to IIS (or you can contact your' ISP).  To install, place the script in a directory or virtual directory' under the domain that you want it to run in.  Open the domain properties in' IIS, go to 'Custom Errors', scroll down to the 404 error and set it to be a' url pointing to wherever you put this file.  Alternatively, if your site is' running on a server with asp.net capabilities, you should be able to use' the system.config file to install.'' USAGE'' This script is for personal use only and can not be used by any corporation' business or other type of orginazition with out the approval of the Author,' Mark Kahn ([email="cwolves@cwolves.com"]cwolves@cwolves.com[/email]).'' Feel free to make any changes or modifications to this script that you' want, although if you make any useful changes, please let me know:' [email="cwolves@cwolves.com"]cwolves@cwolves.com[/email]'' SETTINGSDim MatchFileTypes, DoNotMatchFileTypes, DoNotMatchFiles, SoundexWeight, intMaxSuggestions, MinimumSimilarity, SecondMustMatch, AutoRedirect, JavascriptRedirectAutoRedirect   = False ' If set to true, will automatically redirect to the assumed 'correct' page if there is only one match.JavascriptRedirect = True ' if set to true, will use javascript as opposed to response.redirect to redirect users if necessary.MatchFileTypes   = "asp|cgi|gif|htm|html|jpeg|jpg|txt" ' Only suggest a file of one of these types.  If blank, suggest any file type.DoNotMatchFileTypes = "psd|doc|pdf" ' An alternative to the above variable, will not match any file of these types.DoNotMatchFiles  = "/robots.txt|/global.asa" ' Do not match any of these specific files.  Must use full relative paths.SoundexWeight   = .25  ' A soundex match increases the word Similarity by this percentageintMaxSuggestions  = 15  ' Maximum number of pages to matchMinimumSimilarity  = .4  ' Every match must be at least this percentage of a match (ie .2 = 20% match).  Values generated are not completely intuitive.  Play around with this to achieve desired results.SecondMustMatch  = .8  ' The 2nd-Xth place match must be this percentage of the 1st place match or better (ie if 1st is a 90% match and this is set to .5, only listings with a 45% match or above are shown)%><FONT size="+1"><B>Sorry, We Can't Find That Page...</B></FONT><BR><BR><%sub LoadDictArray(Directory) dim objFSO, files set objFSO = server.CreateObject("Scripting.FileSystemObject") if objFSO.FolderExists(server.mappath("/") & "\" & replace(Directory, "/", "\")) then call LoadDirectory(objFSO.GetFolder(server.mappath("/") & "\" & replace(Directory, "/", "\")), files) if Files <> "" then strDictArray = split(left(Files, len(Files) - 1), "|") else strDictArray = array()end subsub LoadDirectory(Directory, files) Dim extension, folder, file, tpath, size, curDirectory, DirName, filelist size  = directory.size DirName = replace(directory.path, "\", "_") if Application("Size_" & DirName) = size then  FileList = Application("FileList_" & DirName) else  for each file in Directory.files   filelist = filelist & "|" & replace(replace(lcase(file.path), lcase(server.mappath("/")) & "\", ""), "\", "/")  next  Application.Lock  Application("FileList_" & DirName) = FileList  Application("Size_" & DirName)  = size  Application.UnLock end if for each tpath in split(FileList, "|")  if instr(tpath, ".")>0 then   extension = right(tpath, len(tpath) - instrrev(tpath, "."))   if (instr(MatchFileTypes, extension)>0 or MatchFileTypes = "") and instr(DoNotMatchFileTypes, extension)=0 and instr(DoNotMatchFiles, "/" & tpath) = 0  then	Files = Files & tpath & "|"   end if  end if nextend subfunction Soundex(strString) Dim i, strLetter, strCode Soundex = UCase(Left(strString, 1)) for i = 2 to Len(strString)  strLetter = UCase(Mid(strString, i, 1))  select case strLetter   case "B", "P":   strCode = "1"   case "F", "V":   strCode = "2"   case "C", "K", "S": strCode = "3"   case "G", "J":   strCode = "4"   case "Q", "X", "Z": strCode = "5"   case "D", "T":   strCode = "6"   case "L":	strCode = "7"   case "M", "N":   strCode = "8"   case "R":	strCode = "9"   case ".", "/":   strCode = "0"   case else:	strCode = ""  end select  if Right(Soundex, 1) <> strCode then   Soundex = Soundex & strCode  end if nextend functionfunction WordSimilarity(strWord, strSimilarWord, wordSoundex) Dim intWordLen, intSimilarWordLen, intMaxBonus, intPerfectValue, intSimilarity, i, charchk strWord	= lcase(strWord) strSimilarWord  = lcase(strSimilarWord) intWordLen   = Len(strWord) intSimilarWordLen = Len(strSimilarWord) intMaxBonus   = 3 intPerfectValue = intWordLen + intMaxBonus intSimilarity  = intMaxBonus - Abs(intWordLen - intSimilarWordLen) charchk	= ";" for i = 1 to intWordLen  if i <= intSimilarWordLen then   if Mid(strWord, i, 1) = Mid(strSimilarWord, i, 1) then intSimilarity = intSimilarity + 1   if intWordLen <> intSimilarWordLen and Mid(strWord, intWordLen - i + 1, 1) = Mid(strSimilarWord, intSimilarWordLen - i + 1, 1) then intSimilarity = intSimilarity + 1  end if next WordSimilarity  = intSimilarity / intPerfectValue if left(strWord, 1) = left(strSimilarWord, 1) then  if wordSoundex  = soundex(strSimilarWord) then WordSimilarity = WordSimilarity + SoundexWeight end ifend functionfunction Suggest(strWord) Dim strSoundex, i, strSuggestions, intSuggestionCount, strSuggestion, strSuggestionArray, dblSimilarityArray, dblSimilarity, endword endWord	 = right(strword, len(strword) - instr(strword, "/")) strSoundex	= Soundex(endWord) Suggest	 = Split(strSuggestions, "|") intSuggestionCount = intMaxSuggestions - 1 ReDim strSuggestionArray(intSuggestionCount) ReDim dblSimilarityArray(intSuggestionCount) for each strSuggestion in strDictArray  dblSimilarity = WordSimilarity(endWord, right(strSuggestion, len(strSuggestion) - instr(strSuggestion, "/")), strSoundex)  i = intSuggestionCount  do while dblSimilarity > dblSimilarityArray(i) and dblSimilarity >= MinimumSimilarity   if i < intSuggestionCount then	strSuggestionArray(i + 1) = strSuggestionArray(i)	dblSimilarityArray(i + 1) = dblSimilarityArray(i)   end if   strSuggestionArray(i) = strSuggestion   dblSimilarityArray(i) = dblSimilarity   i = i - 1   if i = -1 then	exit do   end if  loop next MinimumSimilarity = dblSimilarityArray(0) * SecondMustMatch for i = 0 to intSuggestionCount  if dblSimilarityArray(i) < MinimumSimilarity then   dblSimilarityArray(i) = ""   strSuggestionArray(i) = ""  end if next Suggest = strSuggestionArrayend functionDim strDictArrayDim URL, Directory, File, Word, Qrystring, Words, Matches, LastWordif request.querystring <> "" then URL   = right(request.querystring, len(request.querystring) - 12) URL   = right(URL, len(URL) - instr(URL, "/")) if InStr(URL, "?")>0 then  Qrystring = right(URL, len(URL) - instr(URL, "?"))  URL   = left(URL, instr(URL, "?") - 1) end if Directory = left(URL, instrrev(URL, "/")) File   = right(URL, len(URL) - instrrev(URL, "/")) call LoadDictArray(Directory) Words   = suggest(URL) if join(Words, "") <> "" then  response.write "The file that you requested does not exist.  There are, however, several files with similiar names to the one that you requested.  Please choose from the links below:<br /><br />" else  response.write "The file that you requested does not exist.  Please check your spelling and try again." end if Matches = 0 for each word in Words  if word <> "" then   Matches = Matches + 1   LastWord = Word   response.write "<a href=""/" & word   if Qrystring <> "" then response.write "?" & Qrystring   response.write """>/" & word & "</a><br />"  end if next if AutoRedirect and Matches = 1 then  if JavascriptRedirect then response.write "<script language=""Javascript"">self.location='http://" & request.servervariables("SERVER_NAME") & "/" & LastWord & "'</script>" else response.redirect LastWord end ifend if%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

AmigosDentro do IIS .. tem um local, onde você define qual vai ser a pagina de erro!No host que eu tinha, dentro do painel HELM dele, eu tinha lá a opção de criar uma pagina personalizada.Podia digitar o fonte da pagina la mesmo, ou upar uma pagina qualquer .. e colocar lá diretão!Acho que vcs estao procurando no lugar errado ...Editando ...No IIS 6, o caminho é:-> Botao Direito em Sites da Web -> Propriedades -> Erros PersonalizadosAí tem uma lista de todos os erros do navegador

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.