最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

ssl - How can I redirect a Flutter web application to https? - Stack Overflow

matteradmin8PV0评论

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>
Post a comment

comment list (0)

  1. No comments so far