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
1 Answer
Reset to default 0I 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条)