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

dart - I published flutter web on iis server and when reload or refresh link gives 404 error - Stack Overflow

programmeradmin2浏览0评论

i am using flutter as a web when publish as a release mode on iis server gives HTTP Error 404.0 - Not Found when reload with url,but ok with click on links.

but localhost work fine, there no any error.

 1.  pubspec.yaml

 url_strategy: ^0.3.0   // add line

  2. index.html       

 <base href="/">   // added line in head tag 


3. main.dart

import 'package:url_strategy/url_strategy.dart';
void main() {
  setPathUrlStrategy();   // add line
  runApp(const MyApp());
}
   

i am using flutter as a web when publish as a release mode on iis server gives HTTP Error 404.0 - Not Found when reload with url,but ok with click on links.

but localhost work fine, there no any error.

 1.  pubspec.yaml

 url_strategy: ^0.3.0   // add line

  2. index.html       

 <base href="/">   // added line in head tag 


3. main.dart

import 'package:url_strategy/url_strategy.dart';
void main() {
  setPathUrlStrategy();   // add line
  runApp(const MyApp());
}
   

Share Improve this question edited Mar 5 at 7:25 ARUN KUMAR asked Mar 3 at 7:40 ARUN KUMARARUN KUMAR 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I have faced this issue before and here is the way to fix your issue.

In your Flutter app go to web folder and you have to add this file exactly as it is.

add this file with the same name>> web.config

Do not change any thing on the following just copy it and paste it inside the file.

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Flutter Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

You already add in your index.html file

On your IIS Server you must to install the IIS URL Rewrite

This way must work correctly when you publish your app.

发布评论

评论列表(0)

  1. 暂无评论