Tokay Posted September 15, 2021 Share Posted September 15, 2021 Hi! I would to redirect all mobile users to anothe url. For example: user connected to the 127.0.0.1:8087 from mobile automatically redirects to the 127.0.0.1:8080 (this is not Unigui url). Quote Link to comment Share on other sites More sharing options...
asapltda Posted September 16, 2021 Share Posted September 16, 2021 unimlabel.caption := '<a href="http://LogisticaSoft.net/" target="_blank">LogisticaSoft</a>' Quote Link to comment Share on other sites More sharing options...
irigsoft Posted September 17, 2021 Share Posted September 17, 2021 On 9/15/2021 at 5:50 PM, Tokay said: user connected to the 127.0.0.1:8087 from mobile automatically redirects to the 127.0.0.1:8080 (this is not Unigui url). Hello, try this: const RedirectURL : string = MyURLtoRedirect; procedure TUniMainModule.UniGUIMainModuleHandleRequest(ASession: TObject; var Handled: Boolean); var sRefererValues : TStringList; begin if (UniSession.ARequest.URI = '/HandleEvent') AND (TRIM (RedirectURL) <> '') AND (UniSession.ARequest.Referer <> RedirectURL) then begin try sRefererValues := TStringList.Create; sRefererValues.Delimiter := '&'; sRefererValues.StrictDelimiter := True; sRefererValues.DelimitedText := Copy (UniSession.ARequest.Referer,POS ('/?',UniSession.ARequest.Referer)+1,Length (s)); //replace url RedirectURL := StringReplace (RedirectURL,'[URL]',Copy (TUniGUISession(ASession).URL,1,POS (':',TUniGUISession(ASession).URL)) + '/',[rfReplaceAll]); //copy other parameters RedirectURL := StringReplace (RedirectURL,'[lgn]',sRefererValues.Values['lgn'],[rfReplaceAll]); finally sRefererValues.Clear; FreeAndNil (sRefererValues); end; //redirect UniSession.AResponse.ResponseNo := 308; UniSession.AResponse.ResponseText := 'redirected'; UniSession.TerminateAfterSecs(2); UniSession.UrlRedirect (RedirectURL); end; end; end; This can be used to redirect from http:// to https:// at startup of session Quote Link to comment Share on other sites More sharing options...
Tokay Posted September 17, 2021 Author Share Posted September 17, 2021 Thank you. I've try your method. Redirect works, but the desctop login form shows for 2-3 seconds. Maybe someone know how to fix this? var RedirectURL: string; begin if upMobile in UniSession.UniPlatform then begin RedirectURL := WebDataModule.SiteRoot; if (UniSession.ARequest.URI = '/HandleEvent') and (TRIM(RedirectURL) <> '') and (UniSession.ARequest.Referer <> RedirectURL) then begin //redirect UniSession.AResponse.ResponseNo := 308; UniSession.AResponse.ResponseText := 'redirected'; UniSession.TerminateAfterSecs(2); UniSession.UrlRedirect(RedirectURL); end; end; end; Quote Link to comment Share on other sites More sharing options...
irigsoft Posted September 17, 2021 Share Posted September 17, 2021 2 hours ago, Tokay said: UniSession.TerminateAfterSecs(2); Replace with UniSession.Terminate; Quote Link to comment Share on other sites More sharing options...
Tokay Posted September 17, 2021 Author Share Posted September 17, 2021 I have already tried, but in this case redirect doesn't works, the form still appears and afteter click on the form browser showed that session is finished. Quote Link to comment Share on other sites More sharing options...
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.