Flutter Web Page Refresh and 404 Not Found Error - flutter

In the main method i used UrlStrategy package as seen in the below because i don't want # in my urls:
void main() {
setPathUrlStrategy();
runApp(const MyApp());
}
In the debug mode when i tested the website, there was no problem. Then i published my website. The homepage is like www.example.com and when i tried to refresh the page with F5, there is no problem. Then i navigate to another page like www.example.com/about-us and try to refresh page with F5 again, and i get "404 not found" error.
To solve this i created .htaccess file in htdocs and wrote inside of this file:
RewriteEngine on
RewritwCond %{REQUEST_FILENAME} !-d
RewritwCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.html [L]
But i started to get 500 Internal Server Error.
There was an existing .htaccess file outside of htdocs. I copied the code above and pasted it inside of existing .htaccess. But again same problem. The codes in existing .htaccess file is given in below:
##################################################
#
# DO NOT EDIT THIS FILE
#
# Create a new .htaccess file in your htdocs
# directory (or example.com/htdocs/ directory)
# to add your own rules or override these rules.
#
##################################################
DirectoryIndex index.php index.html index.htm index2.html
ErrorDocument 403 https://infinityfree.net/errors/403/
ErrorDocument 404 https://infinityfree.net/errors/404/
ErrorDocument 500 https://infinityfree.net/errors/500/
What i have to do?

I created a file called .htaccess in htdocs. And I pasted the codes given below:
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(index\.html|assets|robots\.txt|favicon\.png)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.html [L]
The problem is solved.

Related

Backlink from Instagram throws 404, Need it to correctly redirect to root url instead

My self-coded portfolio website is giving me problems when used as an Instagram profile link (let's say www.myurl.com): the Instagram browser displays a 404 error when clicking the profile link. Clicking "Back to Index" on the 404 page shows the website as it should. After checking the URL, I see that Instagram automatically adds a random string to the domain (like www.myurl.com/?fbclid=PAAaa-Vm9q.../) and I assume my website doesn't know how to redirect this. The issue does not occur on a desktop computer, only mobile.
I'm guessing this random string is an SEO tool, which I woefully do not know how to use.
But I need the website link on IG to go through to my homepage without throwing the 404 error, at a minimum. Is there some kind of code / html document / web hosting / dns setting I need to manipulate to get this to work?
I have a feeling this is an issue caused by DNS settings on Cloudflare since I recently set up a proxy with them to use their global SSL certificate.
Some notes about my website in case they are helpful:
hosting on GoDaddy, recently proxied through CloudFlare for SSL certificate
I have the main domain (www.myurl.com) automatically redirect to a subdomain (sub.myurl.com). This subdomain is actually stored in a folder like www.myurl.com/sub/ .
Website is a CMS built on PHP 5
I tried URL shortener services as a stopgap measure. The only one that solved the problem was shorturl.at, but tiny.url and bit.ly still had the 404 issue. I have no idea why.
I looked at the htaccess document in the subdomain root folder, the contents are below. I think the issue may be that the "base" needs to be "rewritten" to the subfolder (www.myurl.com/sub/) but I'm not sure how to correctly change this code:
RewriteEngine on
# Some hosts require a rewritebase rule, if so, uncomment the RewriteBase line below. If you are running from a subdirectory, your rewritebase should match the name of the path to where stacey is stored.
# ie. if in a folder named 'stacey', RewriteBase /stacey
#RewriteBase /
ErrorDocument 404 /404.html
# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !public/
RewriteCond %{DOCUMENT_ROOT}/public/$1.$2 !-f
RewriteRule (.+)\.(html|json|xml|atom|rss|rdf|txt)$ $1/ [L]
# Add a trailing slash to directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ([^/]+)$ $1/ [L]
# Rewrite any calls to /* or /app to the index.php file
RewriteCond %{REQUEST_URI} /app/$
RewriteRule ^app/ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?$1 [L]
# Rewrite any file calls to the public directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !public/
RewriteRule ^(.+)$ public/$1 [L]
I'm very much a beginner with webhosting / coding / etc so will appreciate an idiot-friendly explanation!! Thanks in advance.

remove # from url gives 404 error angular5

The thing is I was trying to remove the # from the angular 5 application.
I was successful in doing so, the app is also working fine but the problem is the internal links are giving 404 error when I try to reload or refresh the page
for eg,
www.example.com (is working fine on reload and refresh).
----------but----------
www.example.com/jobs (gives 404 error on reload and refresh)
/jobs : is part of routing
Thanks for help in advance.
Create a .htaccess file inside your root folder (next the package.json file) and paste this code to its content:
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
Hope it helps! :)

css and js files are not loaded with multiple .htaccess slimframework

well i have setup slim skeleton directly in public_html where in that directory their is first .htaccess file contain routing to public folder.
first .htaccess contain:
RewriteEngine On
RewriteBase /public/
RewriteRule ^$ public/
due to which my domain is directly pointing to public/index.php
which contain second .htaccess file with slimframework standard .htaccess file:
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
Because of this my css and js files are not loaded inside template and they are going as in console
GET http://domain.com/css/bootstrap.min.css
returning 404 error
I am struugling with this issue from two days but still not able to get where should i change as its working fine on my local server but not over godaddy server.

Deploying Laravel to Bluehost

I was wondering if anyone has had any experience deploying larval to blue host? I was flowing an youtube tutorial that showed how to deploy a larval application to a shared hosting service. It was using Godaddy.com, however, i was using Bluehost, and it didn't work as expected. However I managed to getting to not return an internal server error.
What I did was to configure the .env file so that it had my correct database information and my APP_URL to point to my domain.
The youtube tutorial said I should also remove everything from the public folder and place it in the applications main folder, which on Bluehost is the public_html folder. I also changed the .htaccess and removed the public in the rewrite that handles the redirects for trailing slashed.
Now, when I point to my website, all that is served up is a blank screen. but something seems to be working because I uploaded an html webpage that renders to the browser. I just wondering where do I go from here to get the entire site running.
i'm using php 5.6.
Any help would be great. Thank you
I think you are using shared hosting
Follow these steps
1: After upload files to public_html move all your /public files in public_html folder All files like index.php, .htaccess and assets folder etc
2: Find the following line in index.php
require __DIR__.’/../bootstrap/autoload.php’;
require __DIR__.’/../project/bootstrap/autoload.php’;
change to
require __DIR__.’/bootstrap/autoload.php’;
require __DIR__.’/project/bootstrap/autoload.php’;
That’s it. Well then, have fun.
check that the PHP version is correct for Laravel
in cPanle enable FastCGI for PHP
open file .htaccess located in /public and edit
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteBase /public/
# For security reasons, Option followsymlinks cannot be overridden.
# Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
This is my .htaccess codes which are different in different server.
#Default Setup
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
//bluehost------------
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /
# 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.php [L]

REST API - Not Found Error

I am working on a Rest Api for my application. This is my application structure
api
-config
-modules
--v1
---controllers
---models
-runtime
-tests
-web
backend
common
console
environments
frontend
I tried runing the following url http://192.168.1.4/~user/urshow/api/modules/v1/web/users
I got a Not found Error. I do have a controller named Users inside controllers folder.
My .htaccess file is like this (which is inside urshow/api/web)
RewriteEngine on
RewriteBase /~user/urshow/api/modules/v1/web/
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
I found the solution. I had made some mistakes. First my .htaccess file was incorrect.
i had this line before RewriteBase /~user/urshow/api/modules/web/
i changed it to RewriteBase /~user/urshow/api/web/
also the url which i was trying was also wrong http://192.168.1.4/~user/urshow/api/web/movies/details
correct url is http://192.168.1.4/~user/urshow/api/web/v1/movies/details.
You haven't added the rest of the url to the redirect. Try using this on your last line;
RewriteRule ^(.*)$ index.php$1