Laravel:htaccess在宅基地被忽略了吗? [英] Laravel: htaccess is ignored on homestead?
问题描述
我创建了一个Laravel应用程序,该应用程序是通过Homestead在本地开发的,并且可以在生产服务器上在线运行.
I have created an Laravel app which I locally develop with homestead and which in online on a production server.
我只有www.mydomain.com
的SSL证书,而没有mydomain.com
的SSL证书,
那就是为什么我用htaccess
强制重定向到https://www.*****
的原因.我通过更改文件myproject/public/.htaccess
来做到这一点,如 https://stackoverflow.com/a/13997498/2311074 中所述
I only have a SSL certificate for www.mydomain.com
but not for mydomain.com
,
thats why I force with htaccess
a redirect to https://www.*****
. I did this by changing the file myproject/public/.htaccess
as explained in https://stackoverflow.com/a/13997498/2311074
重定向在我的生产服务器上可以正常工作,但是在带有宅基地的本地环境中没有发生重定向.为什么在本地环境中忽略重定向?
The redirect works fine on my production server but there is no redirect happening on my local environment with homestead. Why is the redirect ignored on my local environment?
这是完整的.htaccess
文件:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
推荐答案
.htaccess
won't work with Homestead, because it uses nginx. .htaccess
is for Apache.
这篇关于Laravel:htaccess在宅基地被忽略了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!