Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rubenochoa's avatar

htaccess not secured

When I use this code:

# BEGIN Laravel

<IfModule mod_rewrite.c>

  RewriteEngine On

  RewriteCond %{REQUEST_URI} !/public
  RewriteRule ^(.*)$ public/ [L]
  # Direct all requests to /public folder

</IfModule>

# END Laravel

# php -- BEGIN cPanel-generated handler, do not edit
# Defina o pacote “ea-php81” como a linguagem padrão de programação “PHP”.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php81___lsphp .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

The browser says that the connection is not secured,

0 likes
4 replies
hugoaf's avatar

The browser doesnt know about your htaccess file. Maybe your browser is referring to the connection between the client (browser) and the server, if you are using HTTP, then your browser is right, that is "not secure", if your server runs also on HTTP secure procolol (HTTPS), try that and if it works, you may use htaccess file to redirect all non-secure requests to the secure port.

rubenochoa's avatar
rubenochoa
OP
Best Answer
Level 2

Is not secured by this edit:

# BEGIN Laravel

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

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

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L] 

</IfModule>

# END Laravel

# php -- BEGIN cPanel-generated handler, do not edit
# Defina o pacote “ea-php81” como a linguagem padrão de programação “PHP”.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php81___lsphp .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

1 like

Please or to participate in this conversation.