Laravel:htaccess在宅基地被忽略了吗?

编程入门 行业动态 更新时间:2024-10-25 20:21:58
本文介绍了Laravel:htaccess在宅基地被忽略了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个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在宅基地被忽略了吗?

本文发布于:2023-11-02 08:32:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551905.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:宅基地   被忽略了   Laravel   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!