Naughty Posted November 14, 2012 Posted November 14, 2012 If I enter in the browser "http://my_address/page.html" and "page.html" is not exist, I will get "File .....\page.html not found." How do I handle this event and to redirect the browser to an existing page "error404.html" or open "http://my_address" Если я ввожу в браузере "http://my_address/page.html" и "page.html" не существует, я получу "File .....\page.html not found". Как мне обработать это событие и перенаправить браузер на существующую страницу "error404.html” или открыть "http://my_address" Quote
lema Posted November 15, 2012 Posted November 15, 2012 404 error page redirection has nothing to do with uniGui. Please use IIS Manager. Quote
Naughty Posted November 15, 2012 Author Posted November 15, 2012 404 error page redirection has nothing to do with uniGui. Please use IIS Manager. uniGui sends to browser the text «File ... not found». Can I change this text? Quote
docjones Posted November 16, 2012 Posted November 16, 2012 404 it's a generic error that webservers send when file page not found. using IIS you can personalize your own error page message. But if your are not using IIS, you need know that unigui use a indy's http server modified version. for doing this, simplest solution is modify the \UniGUI\uIndy\uIdCustomHTTPServer.pas, catch the error after FOnCommandGet event, and put your html code or load it from file. it's not best elegant solution, but it works ! procedure TIdCustomHTTPServer.DoCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); begin if Assigned(FOnCommandGet) then begin FOnCommandGet(AContext, ARequestInfo, AResponseInfo); if AResponseInfo.ResponseNo=404 then AResponseInfo.ContentText:='PUT YOUR HTML CODE HERE'; end; end; Quote
Naughty Posted November 17, 2012 Author Posted November 17, 2012 404 it's a generic error that webservers send when file page not found. using IIS you can personalize your own error page message. But if your are not using IIS, you need know that unigui use a indy's http server modified version. for doing this, simplest solution is modify the \UniGUI\uIndy\uIdCustomHTTPServer.pas, catch the error after FOnCommandGet event, and put your html code or load it from file. it's not best elegant solution, but it works ! procedure TIdCustomHTTPServer.DoCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); begin if Assigned(FOnCommandGet) then begin FOnCommandGet(AContext, ARequestInfo, AResponseInfo); if AResponseInfo.ResponseNo=404 then AResponseInfo.ContentText:='PUT YOUR HTML CODE HERE'; end; end; AResponseInfo.ContentText:='<meta http-equiv="Refresh" content="0; URL=....">'; Thank you! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.