403 Error and Browser Cache - laravel

We have a Laravel Application as Back-end running on a Linux Server.
Some times, when reloading the page, the server returns a 403 Error.
This problem is solved if I clear my Browser Cache, but less than 1 minute using the app, the 403 error appears again.
/public/.htaccess file:
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
DirectoryIndex index.php # This line does the trick
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] </IfModule>
Any clue about it?

Related

Laravel 8 Redirect Http to Https

I'm starting to develop a new big app, and I'm using Laravel 8 this time, and it's the first time.
I trying to Redirect HTTP to HTTPS with .htaccess file but unfortunately it's not working https://app.workfromhere.com.my/ please help me thanks.
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
# 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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I found out you are using cPanel, you can set Force HTTPS Redirect in Domains tap.

Problem loading page "404 not found Error" in Laravel Project

I have created a website that was working fine, but now I am getting 404 not found error.
The live url is glucolight.co.uk
The main page is loading but all other pages show 404 not found.
I have .htaccess file in public folder with below content
<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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have tried putting same .htacces in root, in that case i get 500 general error.
Any solution please.

Laravel MethodNotAllowedHttpException The GET method is not supported for this route. Supported methods: POST

I have Laravel project works as an API, On my local machine it's working currectly but when I uploaded it on the server and send a request with Postman it doesn't send a post request, It's changed to GET request ! I read so many solutions and nothing worked for me.
https://imgur.com/p44fI1W
https://imgur.com/gdVLhXk
https://imgur.com/RKDpEom
My .htaccess file
<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.php [L]
</IfModule>

I'm forcing SSL with htaccess but it isn't working with URLs that link to files

I realised that my site is not redirecting correctly when the URL link to a file (a pdf in this case). The others urls of my site are working perfectly. This is my htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
It's strange because after differents ways of typing my url I found this:
If I type "myweb.com/urltopdf", it is redirected to "https://myweb.com/urltopdf"
If I type "https://myweb.com/urltopdf", URL works
If I type "http://myweb.com/urltopdf", it isn't redirected and the url doesn't work. This case is my problem.
I dont know if it's important but I am using laravel 5.2.
Thanks.
EDIT: It works on firefox and edge but not on chrome.

All page show 404 apart from index

Even /home is 404. I just start learning laravel, I don't know if I did something wrong.
After reinstall composer and created a new project the problem still
exist.
Xampp is running.
Here is the .htaccess in public:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
have you added Route::get(/home, HomeController#index); to your routes file?

Resources