12-20-2021, 10:17 AM
Thanks Kudzu for your feedback! Yes, we do have wildcard SSL certificates for the cases I am looking at. I did some experiments on my own earlier and could successfully redirect from my main web application to a couple of other web applications, so for those I do not need any other solution as it looks like. This is my test code (hard-coded values will be replaced by values read from configuration if I complete this code):
Please let me know if I should do this differently from within my IntraWeb application. We are investigating some other external solution for our non-intraweb applications, as it turns out that some existing clients for these services do not handle redirects properly.
Best regards
Magnus Oskarsson
PS. My other questions above remain.
Code:
procedure TBaseClientServerController.IWServerControllerBaseExecuteRequest(const Url: string;
Request: THttpRequest; aReply: THttpReply; var Handled: Boolean);
procedure CheckForOldHostToRedirect(const OldHost, RedirectBaseUrl: string);
var
RedirectUrl: string;
begin
if ContainsText(Request.Host, OldHost) then
begin
RedirectUrl := RedirectBaseUrl + Request.PathInfo;
if Request.Query <> EmptyStr then
RedirectUrl := RedirectUrl + '?' + Request.Query;
ReportInformation(SafeFormat('Host contains %s, redirecting to %s...', [OldHost, RedirectUrl]));
aReply.SendRedirect(RedirectUrl, 301);
Handled := True;
end;
end;
const
HostCount = 2;
OldHosts: array[1..HostCount] of string = ('m.mydomain.com', 'recipient.mydomain.com');
RedirectBaseUrls: array[1..HostCount] of string = ('https://mydomain.com/m', 'https://mydomain.com/recipient');
var
i: Integer;
begin
for i := 1 to HostCount do
begin
CheckForOldHostToRedirect(OldHosts[i], RedirectBaseUrls[i]);
if Handled then
Break;
end;
end;Please let me know if I should do this differently from within my IntraWeb application. We are investigating some other external solution for our non-intraweb applications, as it turns out that some existing clients for these services do not handle redirects properly.
Best regards
Magnus Oskarsson
PS. My other questions above remain.

