我刚刚使用ELB通过AWS(ACM)将我的HTTP升级到HTTPS。 我的文件夹结构是这样的,
htdocs-
-index.html
-myproject(laravel starts here)
-index.php
-folder(it contains config and all other folders)
现在没有HTTPS重定向代码,它完美运行, 但是,只要我添加AWS ACM提供的此代码,我的目标网页就会完美无缺,但下一条路线会出现404错误。
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
</VirtualHost>
我的laravel网页从
开始https://www.spontieapp.com/mobile
我的httpd.conf内容是, https://pastebin.com/ArUDP6Xg
我的.htaccess是, https://pastebin.com/wU72Zbau
.htaccess存在于/ mobile文件夹
下请协助解决。 感谢
答案 0 :(得分:1)
尝试以下重写规则:
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
...您需要确保将其放在要应用它的站点根目录中的.htaccess文件中,并确保在httpd.conf中具有相应的AllowOverride配置