Laravel SESSION expired 419 and auto redirect - php

So I have this weird problem after I've uploaded my laravel project on a shared hosting. When ever I make any post request is responding with 419. FYI #csrf is included in each form. Everything is working fine on my localhost. I've tried to change the session driver but I had the same response too. Another thing when I ever I call a get request, laravel will redirect me back to the same page.
EDIT
I've contacted my host support, they said that the error is coming from the Mod_security firewall of their shared server, and based on the logs they pulled up, they said the rule ID it generated is globally blocked on their servers. What are the alternative solutions?

Related

Laravel 403 error (production) when doing ajax POST request only in HTTPS

I've been through the web for about 3 hours to find a solution to my issue but can not find out...
I've uploaded my laravel application on a shared host, so the file architecture looks like:
The .htaccess is the laravel default:
All my routes work fine when my website is hosted with HTTP (or in local) but when I switch it to HTTPS (applying from the OVH hosting panel) it breaks all my POST request (via ajax) to 403 error (Can't access... on this server).
Api route example: https://mywebsite.com/api/v1/login
If you have any suggestion, don't hesitate! Thanks.
I tried a lot of things, but I finally got the solution:
In my web hosting (OVH) panel, there was a firewall on the host, I disactivated it.
I regenerated the SSL certificate.
I destroyed cookies and session.
I don't know which one exactly made the trick but it saved my day!

Uploaded Laravel to my shared hosting and I get forbidden on the domain

I know this question has been asked over and over but I can't get my head around it. Why isn't the project showing on the root domain, but do I have to always enter /public to it?
I've tried the command mentioned in this post (and also the tip in the comment). But that didn't work. And if I recall correctly forwarding all incoming requests to /public/index.php?$1 is a potential security vulnerability because .env file can be shown exposing passwords and API keys.
I'm on a shared hosting environment using Laravel 5.2. How can I set this up?

POST Request not working, but GET works an lokal all works

I am trying to do a POST request with AJAX.
This Site http://www.learn-it-up.de/sap-kurse/ do a AJAX POST to http://www.learn-it-up.de/wp-content/themes/lms/framework/courses_utils.php but it returns a 403 forbidden.
When I call the site http://www.learn-it-up.de/wp-content/themes/lms/framework/courses_utils.php direkt in brwoser (GET) it works! So only POST is not working.
When I try this all on my localhost it works too!
So what configurations can I change to get this work?
I can not post the AJAX Request because it is not allowed to publish the code, but as I sag on localhost it is working.
By the way I am using Wordpress.
It could be that the server configuration is rejecting the POST http method. Also maybe you have some mod_rewrite (I'm assuming apache) rules in the server that could be redirecting your post someplace else.
Moreover, the infrastructure or the configuration of both the server and the wordpress instance you are testing to could be entirely different from your environment, maybe you have an nginx in between or some other component that could be interfering, etc.
Compare configurations and infrastructure between your local environment and the server and you will most likely find the answer.

transferred laravel from godaddy to hostgator and routes don't seem to work

laravel was working fine when I am hosting with GoDaddy but recently I transferred my domain to hostgator first time on hostgator and so I moved all laravel contents from GoDaddy to Hostgator by downloading everything from ftp then transferred all files over. Database with godaddy and hostgator are different and so I created database in hostgator and implement everything needed but somehow when I load up my page in hostgator my page loads but when I click on any of the links in the page I keep on getting the 404.html.
At first I thought it was because my database info isn't set correctly because it's my first using using hostgator and their database uses localhost instead of like GoDaddy it has an ip for me to use as a host.
Anyways then I uploaded some other things into hostgator which isn't using laravel just normal php with database info and this works fine. So now I am confused if it is because of laravel or it is hostgator? I have no idea where to start looking for what the problem is
I was told by hostgator that they can migrate contents at a charge and everything will work perfectly the same as it was with godaddy but I figured this is a time I can learn if anything happens
I am sorry if this a stupid question. Can someone please give me a hand? Thanks a lot
my folder structure
-root
-public_html
-user-login (laravel folder)
P.S. I have a free account with aws ec2 and I tried transferring all the files into aws-ec2 and I can see other pages fine just that let's say if I try to login it gives me errors which is normal since I didn't have database setup correctly but at least the links works
Alright, I found out why and pretty much my stupidity I believe.
Somehow, as I said using hostgator (without a domain) I was loading the page using http://ip/myname/laravel/public and I can only see the index page any other links gives me error404.
I was still waiting for my domain transfer at that time so I had to load my page with my ip/username in order to load my pages.
Somehow after my domain is transferred and namespace is set in place.
For example my domain is www.domain.com after the transfer is complete and namespace is setup in hostgator now I can load the page as http://www.domain.com/laravel/public AH~ and all links are working fine as before.
No idea what's the real reason behind this but after this, everything works like a charm now
If anyone has an idea the reason why, I wouldn't mind you posting / commenting here to gain my knowledge

Accessing server through web browser using ip address redirects to localhost

I'm using prestashop to set up an e-commerce website on my cloud server. I was able to successfully install it on the server and it works fine on the server locally, i.e. if I look at the website using localhost on the server. However when I try to access it from a different machine it won't work because, it gets redirected to localhost/index.php? I'm not sure what could be wrong or even where to start looking... any help would be appreciated. Only thing I could think of was the index.php file. It has following 2 lines of code and is generated by prestashop.
I apologize if this is not the correct SO website, as I wasn't sure what the issue could be related to.
Thank you.
When moving an CMS to another domain problems like this often occurs. Most CMS saves the domain they should run on in configuration file oder database. If there is an request for another domain they are sending an redirect (HTTP state code 302) back. I think problem here is that this one is set to localhost.
A short search on google pointed out that prestashop saves a domain name configuration in a mySQL database. Since petrashop 1.5 it should be in a table called PREFIX_shop_url. Before it was saved in PREFIX_configuration as PREFIX_shop_url. But I didn't tested on my own. You should have a look on your own and change the value in database to your new domain.
You could use mysql command line client to connect to database and change the value. If your are not so familiar with SQL you could also use a GUI like phpmyadmin.

Categories