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

i am using flutter as a web when publish as a release mode on iis server gives HTTP Error 404.0 - Not F

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745105402a4611525.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信