如何在laravel中将所有网站请求重定向到https:// www?

时间:2019-12-14 17:17:30

标签: laravel .htaccess

我正在使用htaccess强制将所有请求发送到https://www。代码正常工作,并向https://www发送请求,但问题是它仅加载Webiste的主页,其他显示404错误。 我的Htaccess代码if-

  <IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=302]

  RewriteCond %{HTTPS} =off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=302,L]
  </IfModule>

我的网址是:-https://www.makemyfoam.com/contact 如果我使用:-https://www.makemyfoam.com/index.php/contact 然后就可以正常工作

1 个答案:

答案 0 :(得分:0)

这是我的,并且工作正常(没有“ www”重定向):

# this should be valid because it contains all the required fields
comentario = 
Comentario.objects.create(usuario=request.user, pelicula=pelicula, texto=texto)