HTTPS:Laravel使用.htaccess(public /) [英] HTTPS: Laravel using .htaccess (public/)

查看:85
本文介绍了HTTPS:Laravel使用.htaccess(public /)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的Laravel项目中包括https,而不使用仅使用 htaccess 的godaddy,但没什么大不了的,因为我使用的是 proxypass 从我的SSL认证网站上获得,该网站将传递给我的laravel项目。

I'm trying to include https in my Laravel Project without using godaddy only using htaccess and not that big deal since I'm using proxypass from my SSL certified website that will pass to my laravel project.

我只需要将laravel项目设置为https。

I just need to make my laravel project to https.

所以我试图将此代码添加到位于 public /

So I tried to add this code to my .htaccess located at public/

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://myproject.com/$1 [R=301,L]

这是我的 public / .htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

RewriteEngine On

# 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>

已更新

 <IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

RewriteEngine On

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{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>

我的httpd-vhosts.conf

<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/e-wallet-frontend/public"
ServerName localhost

<Directory "/opt/lampp/htdocs/e-wallet-frontend/public">
   Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

ErrorLog "logs/frontendewallet.com-error_log"
CustomLog "logs/frontendewallet.com-access_log" common
</VirtualHost>

出现 HTTPS ,但浏览器显示找不到对象我的htaccess有问题吗?

the HTTPS appears but the browser says Object not Found is there something wrong with my htaccess?

推荐答案

RewriteRule ^(.*)$ https://www.myproject.com/$1 [R=301,L]

这是我在多个Laravel项目中使用的代码。

This is the code I have on my multiple Laravel projects.

这篇关于HTTPS:Laravel使用.htaccess(public /)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆