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]