I'm trying to enable direct url handling on my Flutter app. I am using beamer and the app works as expected with deep linking within an app emulator, and when using the chrome web browser emulator through vscode.
When I publish the code though, only the main page works. Directly accessing the url doesn't.
When I switch back to the /#/ strategy, everything works and I can access anywhere in the app directly.
This means that the app is not loaded and only the Apache webserver is returning a 404 because it does not recognize index.html of the flutter jS file to be a cgi.
Awhile back I worked with php and there was a way to access url's without using extensions and an override in httpd.conf setting.
Has anyone got this working for flutter navigation 2.0 compiled for web on an apache webserver?
Thanks
create a .htaccess file in the root directory:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]
</IfModule>
Edit httpd.conf for that root directory:
DocumentRoot "/Users/myname/myapp/build/web"
<Directory "/Users/myname/myapp/build/web">
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
Visit: yoursite.com/path/to/flutter/page or wherever you have a route parser