1

I need to force all request to HTTPS rather than HTTP.

For that I have added the following code in to my .htaccess as can be seen below:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This URL is forced to HTTPS: http://localhost/test

but this URL is not forced to HTTPS: http://localhost/test/public/assets/css/custom.css

Mohin Mathakia
  • 324
  • 2
  • 7
  • 1
    Possible duplicate of [Need to redirect all traffic to https](https://stackoverflow.com/questions/3239739/need-to-redirect-all-traffic-to-https) – RiggsFolly Sep 12 '17 at 12:35
  • 1
    Please do a simple google search before asking a question. How much [research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – RiggsFolly Sep 12 '17 at 12:36
  • @RiggsFolly i find everywhere but not getting any solution, try yourself using above code and make sure above 2 URL cases working perfect! – Mohin Mathakia Sep 12 '17 at 13:34

1 Answers1

0

This is straight from the Apache documentation:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

It doesn't look much different than yours but perhaps the minor changes will make a difference with your specific issue.

GuidedHacking
  • 3,628
  • 1
  • 9
  • 59