简体   繁体   中英

I need laravel website to open in https without public in url, how can I do it?

I have created website on Laravel, so the website was being open under www.domain.com/public/. So I searched my answer here and found out this was working for me, after I added this code the page was opening at www.domain.com without public added to the url:

htaccess:

Options -Indexes
<IfModule mod_rewrite.c>
    RewriteEngine on        
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

But now I installed SSL and I want to force it to open a page at https link but I dont know why it won't. I setted my APP URL inside .evn file to https link and added this code to the htacces file:

Options -Indexes
<IfModule mod_rewrite.c>
    RewriteEngine on        
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ https://domain/$1 [L]
</IfModule>

And it now opens webpage every time in https but with additional public in url, when I try to delete public and set code to be:

Options -Indexes
<IfModule mod_rewrite.c>
    RewriteEngine on        
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ https://domain/$1 [L]
</IfModule>

It wont open my website at all. Please if anyone knows a fix to this I will be so much thankfull, best wishes!

How about this one?

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

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

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

RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L]

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM