Jump to content

Recommended Posts

Posted

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"

Posted

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?

Posted

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;

Posted

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!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...