seturlstrategy- page reload not working :Flutter web 2.0 - flutter-web

I have used setUrlStrategy(PathUrlStrategy()); to remove # from the url, but since then my pages stopped reloading after I deploy my project on web, it shows 404 page not found. but works perfectly on localhost.
if I remove setUrlStrategy(PathUrlStrategy()); and build again to deploy on web it works. but that # shows on url.
Can anyone help?
p.s: I used my project on non root location, and have already added my project name in index file, my project works if I open first page to next file, but not directly when open next file from url.

ok i found the problem, it was because i didn't use .htaccess file.
here is htaccess code if anyone get same problem.
RewriteEngine On
RewriteBase /myproject/
RewriteRule ^index\.html$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myproject/index.html [L]
</IfModule>
put this file where your index file is.

Related

How to redirect HTML index file to subfolder directory?

I have created a subfolder to access my HTML website. But the problem is, it is not running on the subdirectory URL but with the index.html aliases.
e.g. https://example.com/my-html-site/index.html (the website running the whole page).
But I want a simple redirection to run the website under the subdirectory like this below,
https://example.com/my-html-site/ (when I hit this URL then it shows a blank page).
Is there any way to redirect the https://example.com/my-html-site/index.html to https://example.com/my-html-site/ via htaccess file rules?
Thanks in advance,
Based on your shown samples could you please try following. Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ $1/index.html [L]

Mod Rewrite tweak to ignore asset directories

I'm configuring Expression Engine on Windows using IIS and have ISAPI v3 Rewrite installed.
It's partly working. The main site and subpages work but needs to be modified because some web page assets are stored in similarly named directories.
The recommended Rewrite provided by Ellislabs is this and I've modified it a little to work with our Win 2012 IIS 8 server:
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) abc/$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ abc/index.php?/$1 [L]
For example, the URL http://oursite.example.com/abc works.
Subpages are mostly working and I suspect this applies to any page really but I'm noticing it on subpages. It removes index.php and mostly loads, such as http://oursite.example.com/abc/subdept/page/
However our developer has some assets kept in a server directory named /uploads/abc/ so if a page refers to this directory, it fails to load those assets because it contains the same name, "abc".
Thus, what is the best way to handle this?
I'm guessing I can either tell it to ignore "uploads/cls" or correct the current Rewrite so that it only looks at the first "abc". I'd like for the solution to cover most similar issues that would arise so I don't have to keep modifying it. We have 12 sites and I'll have to apply the solution to each one.
Everything I've tried hasn't worked.
Also, I thought !-f and !-d would tell it to ignore it if the file or directory existed and that doesn't seem to be working as I'd expect here because these images in /uploads/abc/ do exists.
Thanks!
--
Additionally just trying to get it to work at all, I tried adding a htaccess file with "RewriteEngine Off" in the /uploads/abc/ directory and that failed to fix it.
I also tried to add this after each comment and it fails to fix it:
RewriteCond %{REQUEST_URI} !^/excluded-folder/.*$
Seeing how both of the above attempts fail to fix it, I'm wondering if there could be something else going on. Any ideas?
My rewrite was fine. The problem turned out to be code within an Expression Engine template that the in house developer created. They updated the code and the images are loading fine now.

Codeigniter sub-folder multiple controllers

Here is my htaccess file and it works somewhat. Not matter what controller I specify it always goes to the home page
<IfModule mod_rewrite.c>
RewriteEngine On
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|css|js)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
This is my website URL
http://automationmetrics.local/automation/
Thoughts?
Some things I usually check when this happens to me:
Have I enabled the mod_rewrite module in Apache?
Have I set $config['index_page'] to blank?
If the above works, here's the one that I use, that's working on my end:
https://gist.github.com/petrepatrasc/6925413
If you're STILL out of luck, then try fiddling with the $config['uri_protocol'] parameter - I remember that I could only get it to work on Windows (with IIS at the time) using REQUEST_URI as a value. Might be related to that.
The first two rules get triggered on all the files, just like it says in the comment. So this one:
RewriteCond $1 !^(index\.php|css|js)
seems redundant and removing it should solve the issue you're having.

RewriteCond to skip actual directories seems to be ignored

My problem is that The RewriteRule is still matching when I visit a physical directory, e.g. http://a-domain.com/foo/ where foo is a normal directory in the web root.
the .htaccess file has:
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .? index.php [L]
It works fine on my dev server but not on a live WHM/CPanel server. I'm a bit lost.
I've tested this on my cpanel website and you're right and I found out where's the problem. when you try to access a folder in your website that doesn't have default file (index) , it tries to access the file that is responsible for 403 HTTP code, and because that doesn't exist, it rewrites URL to index.php.
All you have to do is add this to above of your .htaccess file:
ErrorDocument 403 /index.php?type=err&code=403
I tried this on a VM which mirrors my own shared service and it works fine for me. Have you got another .htaccess in the foo directory? If so, then the rewrite engine will ignore your one in DOCROOT and use this instead?
The /foo/ dir has basic authentication so it was failing when %{REQUEST_FILENAME} contained a non-existent file /home/the_user/public_html/401.shtml. I didn't think this was an issue because the basic authentication worked, and when I cancelled the auth prompt I was being served a standard 401 file. Usually when those ErrorDocument files are missing, Apache says Additionally, an error of type 404 was encountered while trying to use an ErrorDocument to handle the request.

vanilla 2 broken links

I have a vanilla 2.0.18b2 installation on my webserver in a subfolder. Forum works, but I can't sign in. When I click a link "sign in" the page goes blank. I think that this is a problem with .htaccess file cause I had a working solution but I wanted to change something and broken the file.
Another thing is that, when I am typing forum.mysite.com it says:
Fatal error: Class 'Gdn' not found in /bootstrap.php on line 47
when I type mysite.com/forum it view the website but with no styling, and when I click a link it goes 500 Internal Error.
Only when I type mysite.com/forum/index.php it looks normal.
My .htaccess file looks like that:
# Modified
# If you modify this file then change the above line to: # Modified
<IfModule mod_rewrite.c>
RewriteEngine On
# Certain hosts may require the following line.
# If vanilla is in a subfolder then you need to specify it after the /.
# (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
RewriteBase /forum/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
#RewriteRule ^$ index.php/$1
</IfModule>
Try clearing the cache by deleting all the files and folders inside the cache folder.
Was facing the exact same problem and clearing the cache solved the issue!
Try changing the RewriteRule to this
RewriteRule ^(.*)$ index.php?p=$1 [QSA,L]

Resources