Apache .htaccess使用laravel重定向到ssl
我正在尝试使用.htaccess在laravel中的登录url上重定向到ssl 登录url看起来像:four.number.for.ip/auth/Login 如果我使用Apache .htaccess使用laravel重定向到ssl,apache,.htaccess,redirect,ssl,Apache,.htaccess,Redirect,Ssl,我正在尝试使用.htaccess在laravel中的登录url上重定向到ssl 登录url看起来像:four.number.for.ip/auth/Login 如果我使用 RewriteCond %{SERVER_NAME} login RewriteRule .* https://%{SERVER_NAME} [R=301,L] 它不起作用。我试过了 %{HTTPS} !=on 它是有效的。 另外,%{SERVER_NAME}返回ip/auth/login(我确信这一点,因为https!
RewriteCond %{SERVER_NAME} login
RewriteRule .* https://%{SERVER_NAME} [R=301,L]
它不起作用。我试过了
%{HTTPS} !=on
它是有效的。
另外,%{SERVER_NAME}返回ip/auth/login(我确信这一点,因为https!=on works)
我不明白这为什么行不通 这应该适合你。让我知道结果如何
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/auth/login [NC]
RewriteCond %{HTTPS} !^on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
编辑以给出完整的规则。应该是这样的
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/auth/login [NC]
RewriteCond %{HTTPS} !^on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
这应该对你有用。让我知道结果如何
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/auth/login [NC]
RewriteCond %{HTTPS} !^on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
编辑以给出完整的规则。应该是这样的
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/auth/login [NC]
RewriteCond %{HTTPS} !^on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
这不起作用,因为在laravel中,%{REQUEST_URI}只是“index.php”,而%{HTTP_HOST}是ip/auth/login。。。它应该与服务器一起工作,因为服务器名包含登录名,但我似乎不知道如何发布您的整个htaccess,所以我不必猜测您有什么。此外,这应该放在您的htaccess文件的顶部。Options+FollowSymLinks RewriteEngine On RewriteCond%{REQUEST_FILENAME}-已重写COND%{REQUEST_FILENAME}-f RewriteRule^index.php[L]RewriteCond%{SERVER_NAME}登录RewriteRule.*https://%{SERVER_NAME}[R,L]我在问题中的意思是。但是我上面的规则不是在后面。这不起作用,就像在laravel中一样,%{REQUEST_URI}只是“index.php”,而%{HTTP_HOST}是ip/auth/login。。。它应该与服务器一起工作,因为服务器名包含登录名,但我似乎不知道如何发布您的整个htaccess,所以我不必猜测您有什么。此外,这应该放在您的htaccess文件的顶部。Options+FollowSymLinks RewriteEngine On RewriteCond%{REQUEST_FILENAME}-已重写COND%{REQUEST_FILENAME}-f RewriteRule^index.php[L]RewriteCond%{SERVER_NAME}登录RewriteRule.*https://%{SERVER_NAME}[R,L]我在问题中的意思是。但我的规则高于一切,而不是以后。