Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用强制HTTPS访问Laravel.htaccess_Laravel_Apache_.htaccess_Ssl_Https - Fatal编程技术网

使用强制HTTPS访问Laravel.htaccess

使用强制HTTPS访问Laravel.htaccess,laravel,apache,.htaccess,ssl,https,Laravel,Apache,.htaccess,Ssl,Https,我在托管我的Laravel网站的根目录中使用此.htaccess文件,因此访问者不会在URL地址中看到/public/in: RewriteEngine on RewriteCond %{HTTP_HOST} ^my-domain.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.my-domain.com$ RewriteCond %{REQUEST_URI} !public/ RewriteRule (.*) /public/$1 [L] 但到目前为止,

我在托管我的Laravel网站的根目录中使用此.htaccess文件,因此访问者不会在URL地址中看到/public/in:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^my-domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.my-domain.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

但到目前为止,我还没有找到一个简单的解决方案来添加强制HTTPS重定向。有什么建议吗?

请使用.htaccess强制域使用https

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]

使用以下代码修改您的.htaccess:

<IfModule mod_rewrite.c>
Options -Indexes 
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
</IfModule>

选项-索引
重新启动发动机
重写cond%{HTTPS}关闭[或]
重写cond%{HTTP_HOST}^www\。[北卡罗来纳州]
重写cond%{HTTP_HOST}^(?:www\)?(.+)$[NC]
重写规则^https://%1%{REQUEST_URI}[L,NE,R=301]
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?$1[L,QSA]
RewriteCond%{THE_REQUEST}^[A-Z]{3,}\s(.*)/index\.php[NC]
重写规则^1[R=301,L]
这将对您有所帮助 您应该在下面的.htaccess中尝试

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]
重写cond%{HTTPS}!在


重写规则(.*)$1[R=301,L]

这与Laravel有什么关系?