Redirection of the site from HTTPS to HTTP


Hey guys, I know its a very long time break but now I am back with this amazing blog, at least for me. 😀

So these days I was working on a project and after completing it I need to upload it on AWS’s EC2 to make this available for everyone. So I created the EC2 instance and upload the project folder in it. after that, I tried to run the instance through the IP address. and the site runs successfully! but but but the CSS wasn’t loaded and the routes are redirecting to the https. I was like man what’s going on!!!

I checked every configuration on EC2 I checked every config file in my project. but nothings working. The site keeps redirecting routed into https. I was literally clueless. Because I haven’t made any settings for https. The project was in the Laravel 5.8 version. In that, in app/Providers/AppServiceProvider.php you can make the setting in boot function. Like this:

public function boot(){
       \URL::forceScheme(‘http’);
        Schema::defaultStringLength(191);
}

I made changes in that to force HTTP, but it wasn’t working. And without CSS and js the site was looking actually horrible. After that, I shared the link with another person and mirracally it worked!!! I was like what is wrong with my system man! Then clear history and catch data from Google Chrome and it worked on my system too with all the CSS. but routes are kept redirecting to https, and CSS was not applying to any other page. It was applying only on the index page.

So I was searching in Google for redirecting https to HTTP. And guess what, All the results I am getting are redirecting from HTTP to https. I thought wow I am a unique person. At that movement only I have decided that if I will get the solution then I am surely gonna write a blog on it, and here I am A blog with its solution.

I have used a boilerplate in the project and there is a meta tag. yes, it was a meta tag that was causing the trouble. Here is that meta tag.

<meta http-equiv=”Content-Security-Policy” content=”upgrade-insecure-requests”>

I removed this tag from the header and everything was working smoothly.

I hope you like this blog.

Thank you for reading.
Happy coding! 🙂

Comments are closed.

Create a website or blog at WordPress.com

Up ↑