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
Php 使用htaccess将所有路由重定向到Laravel中的https/ssl_Php_Apache_Laravel - Fatal编程技术网

Php 使用htaccess将所有路由重定向到Laravel中的https/ssl

Php 使用htaccess将所有路由重定向到Laravel中的https/ssl,php,apache,laravel,Php,Apache,Laravel,如何重定向此文件(我的网站位于子文件夹中) 如何将所有路由重定向为https 这样行吗 RewriteRule ^(.*)$ public/$1 [L] 重新启动发动机 重写cond%{HTTPS}=在…上 重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301] 重写规则^(.*)$public/$1[L] 您可以在当前规则之前使用此规则 <IfModule mod_rewrite.c> RewriteEngine On

如何重定向此文件(我的网站位于子文件夹中)
如何将所有路由重定向为https

这样行吗

RewriteRule ^(.*)$ public/$1 [L]

重新启动发动机
重写cond%{HTTPS}=在…上
重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
重写规则^(.*)$public/$1[L]

您可以在当前规则之前使用此规则

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
试试这个

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]