最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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>
发布评论

评论列表(0)

  1. 暂无评论