【发布时间】:2019-06-29 23:40:09
【问题描述】:
我在 Laravel 上创建了网站,所以该网站在 www.domain.com/public/ 下打开。所以我在这里搜索了我的答案,发现这对我有用,在我添加此代码后,页面在 www.domain.com 上打开,而没有将公共添加到 url:
htaccess:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
但现在我安装了 SSL,我想强制它在 https 链接上打开一个页面,但我不知道为什么它不会。我将 .evn 文件中的 APP URL 设置为 https 链接,并将此代码添加到 htacces 文件中:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ https://domain/$1 [L]
</IfModule>
当我尝试删除公共并将代码设置为:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ https://domain/$1 [L]
</IfModule>
它根本不会打开我的网站。请如果有人知道解决此问题的方法,我将非常感谢,并致以最良好的祝愿!
【问题讨论】:
-
添加此代码
RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] -
它给了我 403 禁止错误页面
-
你能分享你的文件夹结构吗..在服务器中使用
-
你能说得更具体点吗,我对 laravel 有点陌生,什么文件夹结构?我的根文件在 resources/views/ 中,公共文件在包含 js/images/css 的站点根 public_html 中
标签: php laravel .htaccess environment-variables