admin管理员组

文章数量:1023018

Ok I created my first web application with Flutter, setup SSL and have a domain with two flavours.

and

setup on IIS.

How can I redirect http to https with Flutter?

I could create Url rewrite server side but I would love to do via Flutter.

Is there such a configuration available?

Ok I created my first web application with Flutter, setup SSL and have a domain with two flavours.

http://example and

https://example setup on IIS.

How can I redirect http to https with Flutter?

I could create Url rewrite server side but I would love to do via Flutter.

Is there such a configuration available?

Share Improve this question asked Nov 18, 2024 at 20:47 CodeNewbieCodeNewbie 191 silver badge5 bronze badges 1
  • Do you think that only formatting the url string could be work? Like if you receive hhtp format it to https and if not exist return an error. – Alexandre B. Commented Nov 19, 2024 at 0:41
Add a comment  | 

2 Answers 2

Reset to default 1

The SSL redirection should be setup on your DNS and Hosting service rather than in Flutter web implementation or any Web implementation for that matter. Please check with your DNS provider and Hosting provider on SSL certificate installation and enabling SSL redirection.

Since the server is IIS I a added the following web.config to handle the https redirection by using the Rewrite Module

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="HTTPS force" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Ok I created my first web application with Flutter, setup SSL and have a domain with two flavours.

and

setup on IIS.

How can I redirect http to https with Flutter?

I could create Url rewrite server side but I would love to do via Flutter.

Is there such a configuration available?

Ok I created my first web application with Flutter, setup SSL and have a domain with two flavours.

http://example and

https://example setup on IIS.

How can I redirect http to https with Flutter?

I could create Url rewrite server side but I would love to do via Flutter.

Is there such a configuration available?

Share Improve this question asked Nov 18, 2024 at 20:47 CodeNewbieCodeNewbie 191 silver badge5 bronze badges 1
  • Do you think that only formatting the url string could be work? Like if you receive hhtp format it to https and if not exist return an error. – Alexandre B. Commented Nov 19, 2024 at 0:41
Add a comment  | 

2 Answers 2

Reset to default 1

The SSL redirection should be setup on your DNS and Hosting service rather than in Flutter web implementation or any Web implementation for that matter. Please check with your DNS provider and Hosting provider on SSL certificate installation and enabling SSL redirection.

Since the server is IIS I a added the following web.config to handle the https redirection by using the Rewrite Module

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="HTTPS force" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

本文标签: sslHow can I redirect a Flutter web application to httpsStack Overflow