[英]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/.我在 Laravel 上创建了网站,因此该网站在 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:
所以我在这里搜索了我的答案,发现这对我有用,在我添加此代码后,页面在 www.domain.com 上打开,而没有将 public 添加到 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.但是现在我安装了 SSL,我想强制它在 https 链接上打开一个页面,但我不知道为什么它不会。 I setted my APP URL inside .evn file to https link and added this code to the htacces file:
我将 .evn 文件中的 APP URL 设置为 https 链接,并将此代码添加到 htacces 文件中:
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:现在,当我尝试删除 public 并将代码设置为:
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] RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://% {HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L] 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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.