Flutter web: Opening direct URL navigation working on local but not after deployment - flutter-web

Even though there exists one Question that is already opened I didnt understand the approaches, but first to the problem itself.
On my local machine my routing works fine.
But when I host it I have the problem that I can navigate to a domain: http://www.example.com but not to a domain http://www.example.com/privacy-policy by direct URL Navigation.
The approaches that were suggested looked like:
htaccess file:
So basicly this approach suggested adding these lines to my htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteRule . /index.html [L]
I did and my whole file then looked like this as well. But it didnt change a thing. So did I something wrong? Should I implement the htaccess somehow?
Adding to Firebase.json:
The other suggestion was adding following code to my firebase.json file:
"hosting": {
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
}
My problem is that I dont have a firebase.json file, so what shall I do with this snippet? Is it only relevant when you use firebase hosting?
So I saw the both approaches but I didnt understand how to implement them. I get that the essential problem is trying to push the route on the same index.html file, but Im not understanding how to properly tackle the behaviour. Maybe I dont have the background knowledge to implement the solutions properly

Related

Internal rewrite to remove directory from url with htaccess

I've searched and tried many tutorials and problem solutions but couldn't achieve what I want.
If user open domain.com/xxx.php he see the content of domain.com/hosting/xxx.php
This
RewriteRule ^xxx.php$ /hosting/xxx.php
Works perfectly what i want to do, but there are over 150 pages in hosting directory and writing rules for each page does not seem right? any possible way to do it dynamically?
I tried this solution it works but it try to find those pages which are currently at root domain.com/xxx.php inside domain.com/hosting/
I search slimier questions have been asked many times before but non of the answer worked for me.
You need to also take care of reuests to the shortened, rewritten URL:
RewriteEngine on
RewriteRule ^/?hosting/(.*)$ /$1 [END,NC,R=302]
RewriteRule ^/?(.*)$ /hosting/$1 [END]

Joomla - htaccess Redirects Error

I've had a Joomla 2.5.28 site for quite a while now and recently changed hosting providers. On the new server I managed to get Joomla updated to 3.2.7 and get it to run normally.
Now for the tricky part:
On my previous hoster I had a second installation being kind of the gateway to the other site. It just lets you select language and that's it.
My domain is www.cyclingtoserve.at with Joomla Main being /joomla and Joomla portal being /3.1
I figured by adding a REDIRECT rule from / to /3.1 I could get the portal up and running again. Sadly not.
This is what I get:
I thought I could undo this by deleting the .htaccess file. The problem lives on though.
I've tried just about everything. Help is VERY MUCH appreciated!
Edit01: A bit more info may be interesting.
The Joomla install is in /joomla while the other page is in /3.1
The .htaccess file however was in the root directory.
Edit02: I have managed to remove the wrong redirection. Question is: What is the correct way to redirect people from www.cyclingtoserve.at to /3.1? (without it showing up in the address)
Edit03: Here is a graphical representation (FTP) of the folder structure.
ftp
In order to avoid the redirect loop, you need to first check to see if your are already in the /3.1/ folder. Try this:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/3.1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://%{HTTP_HOST}/3.1/$1 [L,R]
Sadly I've had to give up using .htaccess for the redirection.
I would have loved the recommended way (and still would like to know how).
Solution:
index.html in root has the following lines:
<frameset rows="100%" frameborder=0 framespacing=0 border=0>
<frame src="http://cyclingtoserve.at/3.1/" name="Content" noresize>
<noframes>
It may be the quick and dirty way of dealing with this issue, but it works.
If you can reproduce the same results with .htaccess, I'd love to tag it as an answer.

net::ERR_INCOMPLETE_CHUNKED_ENCODING

I use .htaccess to rewrite url from someurl.com/ to someurl.com/public/. First .htaccess in www root contains this:
DirectoryIndex ./public/
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ./public/$1 [QSA]
and second one in folder /public/ contains this:
DirectoryIndex _main.php
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ./?params=$1 [QSA]
And the problem is when I open url someurl.com/ without "public". Page is loaded correctly, but in Google Chrome console I got error: net::ERR_INCOMPLETE_CHUNKED_ENCODING. When I open url someurl.com/public/ page loads without any error.
Any ideas, please?
In my case, the problem was cache-related and was happening when doing a CORS request.
I post my response here cause this is the first resource I found on Google for net::ERR_INCOMPLETE_CHUNKED_ENCODING error.
Forcing the response header Cache-Control to no-cache resolved my issue:
[ using Symfony HttpFoundation component ]
<?php
$response->headers->add(array(
'Cache-Control' => 'no-cache'
));
I had this issue when trying to access some parts of the WP admin area, I managed to resolve it by adding the below to my functions.php file;
add_filter('wp_headers', 'wpse167128_nocache');
function wpse167128_nocache($headers){
unset($headers['Cache-Control']);
return $headers;
}
We had net::ERR_INCOMPLETE_CHUNKED_ENCODING problem in case of HTML, which contained too much empty lines. Some browsers had difficulties with interpretation of long files.
Once we made applied code cleaning in our templates by cleaning code from empty lines, all was perfect.
I was also facing same issue. Finally i got this was the permission issue on cache folder.
I decided changing the file : /etc/apache2/mods-enabled/cgid.conf
Adding the following code snippet:
<IfModule mod_cgid.c>
CGIDScriptTimeout 60
</IfModule>
This problem is really general, in my case I deactivated the WP Super Cache plugin, and didn't get the bug anymore, but this is so general that no one can really help you because of different configurations of servers/wordpress
In my case, the problem was the Windows anti-virus software (Kaspersky). Turning it off, the problem was gone :/
For me it was the Zend PHP Opcache. It had reached its memory limit and could no longer cache all scripts. This was a problem for a massive code base like Magento 2.
Increasing the memory limit solved the issue after weeks of banging head on desk.
It is about server side problem.
The user has running web service does not right access to web server cache folder.
Make sure nginx user can write to /var/lib/nginx (or /var/cache/nginx in some distros).
Make sure nginx user can write to the folder (find the nginx user form nginx configuration file is located usually in /etc/nginx/nginx.conf)
Give the right access (chown -R nginx:nginx /var/lib/nginx/)
Reload the service(-service nginx reload -in centos)

The requested URL /public_html/ was not found on this server

I'm working on a local MAMP website. I use a micro MVC framework to use friendly urls
so I don't need to call index.php (which is inside of public_html directory) in the urls.
To achieve that, I have the following htaccess:
RewriteEngine on
RewriteCond %{REQUEST_URI} !public_html/
RewriteRule (.*) /public_html/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
Then I have the following line in /etc/hosts
127.0.0.1 mywebsite
Also, I have the following in httpd.conf
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/mywebsite"
ServerName mywebsite
</VirtualHost>
So if I simply call http://mywebsite from the browser, the whole thing works smoothly.
So what's the problem?
The problem appears if I try to reach the same page from another machine in my LAN.
So if I write http://192.168.1.15/mywebsite the answer is:
Not Found
The requested URL /public_html/ was not found on this server.
I get the same message if I call http://localhost/mywebsite from my own machine.
I have the feeling that is something related to .htaccess, but I've been trying a
lot of different ideas I've found in the web, and nothing works.
I'd like to fix this, because I need other people to check the website from their machines.
If you have any clue please help. Thanks a lot.
Edit: I can't solve this, so as a temporary fix I've created a free account at AppFog for my team to be able to access the page until we go to production.
After all these years, I thought that computing would be easier... it's getting harder, actually. The htaccess file is a huge mistery to me! Thanks anyway :)
By the way... as I told you, I've found a way to fix the problem. The funny thing is I have to use a different .htaccess file. I thought you could be interested, provided that it seems you like computing stuff :)
This is the .htaccess that works in my LAN debian server:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/(www/.*)$
RewriteRule ^(.*)$ index.php [QSA,L]
As you can see, it's different from the one I showed you at my first post. My conclusion? Well, even when I always try to keep things simple, life shows me one and another time that everything can be more complicated. Look at the .htaccess file. It's so funny... I've learnt to work with it by using different combinations of code.
Isn't it crazy? Yes it is. Please let's do understandable software. Thank you!
Ok, I've been trying a lot of different things and all of them fail. The only solution I've found is to install the web site in a separated LAN debian server. Everything works ok in that way, but it's not possible to make it work from my machine with MAMP.
Why not? Well, I don't know. After a lot of years in computing, I've learnt to say "I donĀ“t know", you know what I mean.
I've been working for a few days with an AppFog account for free but, you know, that thing cannot work when you put a database and the whole thing there. Obvious.
So at the end the only solution I've found has been to put everything at that local LAN debian server.
Thank you anyway :)

How to perform htaccess rewrite

Here is the summary of my problem.
I have created a Facebook like button. It works correctly most of the time, however not when following the link from somebody's actual "like" post. It seems that Facebook is adding some more info to the URL. For instance, I have
www.example.com/blog.php/6
but Facebook adds
www.example.com/blog.php/6?fb_action_ids=10201090685057512&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=288381481237582
When a user follows this link they get a Mysql syntax error. If they follow the first link there is no problem. I thought I could just strip off all that extra text from the URL.
I created a .htaccess file and placed it in my root directory on GoDaddy.
I Tried several different rewrites.
Nothing has worked. This is the latest thought I tried:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*&)?fb_action_ids=
RewriteRule ^(.*)$ $1?%1 [R=301]
Do I need to change my .htaccess file or is there another way to solve this problem?
Thanks for the help.

Resources