Web Security

What Is HTTP Strict Transport Security (HSTS)?

A security header that tells browsers to only connect to your website over HTTPS. Once a browser receives the HSTS header, it will automatically convert all future HTTP requests to HTTPS for the specified duration, preventing protocol downgrade attacks and cookie hijacking.

In Laravel Applications

Set the HSTS header in Laravel middleware: $response->headers->set("Strict-Transport-Security", "max-age=31536000; includeSubDomains"). Also force HTTPS in production with URL::forceScheme("https") in your AppServiceProvider.

Example

Without HSTS, an attacker on a public WiFi network could intercept the initial HTTP request to your site and redirect the user to a fake version. With HSTS, the browser refuses to connect over HTTP.

Related Terms

Monitor Your Laravel Application's Security

StackShield continuously checks your Laravel application from the outside, catching security issues before attackers find them.

Start Free Trial