我创建了一个Laravel应用程序,该应用程序是通过Homestead在本地开发的,并且可以在生产服务器上在线运行.
I have created an Laravel app which I locally develop with homestead and which in online on a production server.
我只有www.mydomain的SSL证书,而没有mydomain的SSL证书, 那就是为什么我用htaccess强制重定向到www.*****的原因.我通过更改文件myproject/public/.htaccess来做到这一点,如 stackoverflow/a/13997498/2311074 中所述
I only have a SSL certificate for www.mydomain but not for mydomain, thats why I force with htaccess a redirect to www.*****. I did this by changing the file myproject/public/.htaccess as explained in stackoverflow/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 .* %{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 .* 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不适用于Homestead,因为它使用nginx . .htaccess用于Apache.
.htaccess won't work with Homestead, because it uses nginx. .htaccess is for Apache.
更多推荐
Laravel:htaccess在宅基地被忽略了吗?
发布评论