title: Redirect http to https in laravel 5.2
body: <p>I have a Laravel 5.2 project. Recently, I installed an SSL certificate on my website so when I type <code>https://example.com</code> in the browser it works but when I write <code>example.com</code>, it connects by HTTP.</p>
  
  <p>To fix that, I added these lines to my <code>.htaccess</code> file:</p>
  
  <pre><code>RewriteCond %{HTTPS} !=on
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  </code></pre>
  
  <p>After that, when I type <code>example.com</code>, the browser redirects me to <code>https://example.com</code>. That's perfect.</p>
  
  <p>The problem is when I try to access the URL <code>http://example.com/download/get/book/volume2</code>, it doesn't redirect me to HTTPS. It redirects me to the index page. If I add the <code>s</code> of <code>https</code> in the URL it works fine but I need the app to redirect me from HTTP to HTTPS.</p>
  
  <p>The route in routes file:</p>
  
  <pre><code>Route::get('download/get/book/{book}'
  </code></pre>
  
  <p>That route opens a PDF file that I have in <code>privates/storage</code> folder in the browser's tab.</p>
  
  <p>EDIT:</p>
  
  <p>My .htaccess file:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  &lt;IfModule mod_negotiation.c&gt;
      Options -MultiViews
  &lt;/IfModule&gt;
  
  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}]
  
  # require SSL 
  RewriteCond %{HTTPS} !=on
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  </code></pre>
  
  <p></p>