Ada*_*dam 5 php .htaccess laravel-5
我创建了一个 Laravel 应用程序,我在本地使用 homestead 开发该应用程序,并在生产服务器上在线运行。
我只有 SSL 证书,www.mydomain.com但没有mydomain.com,这就是为什么我强制htaccess重定向到https://www.*****. 我通过更改文件来做到这一点,如/sf/answers/979824891/myproject/public/.htaccess中所述
重定向在我的生产服务器上工作正常,但在我的本地环境 homestead 上没有发生重定向。为什么在我的本地环境中重定向被忽略?
这是完整的.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>
Run Code Online (Sandbox Code Playgroud)
我有类似的问题。我的生产服务器使用 Apache,我需要 mod_rewrite。Laravel 甚至附带了开箱即用的 .htaccess 文件!
这是我在这里找到的一个优雅的解决方案。
将“type: apache”添加到我的 Homestead.yaml 文件中。
站点:
地图:mylocalapp.com
到:/home/vagrant/code/public
类型:阿帕奇
再配置vagrant来使用Apache。
流浪者向上--规定
首先SSH进入homestead并运行命令
flip
Run Code Online (Sandbox Code Playgroud)
它会停止nginx并且会开始apache。
现在你的.htaccess意志起作用了。
聚苯乙烯
type: apache另一个选项是在文件中使用Homestead.yaml。但由于某种原因它对我不起作用。