使用Angular和Apache从http重定向到https不工作
我安装了SSL证书,我想将所有流量从http重定向到https。我已将此部分添加到Apache服务器:使用Angular和Apache从http重定向到https不工作,apache,angular,redirect,https,routing,Apache,Angular,Redirect,Https,Routing,我安装了SSL证书,我想将所有流量从http重定向到https。我已将此部分添加到Apache服务器: IncludeOptional conf.d/*.conf <VirtualHost *:80> ServerName www.memoriesgameseries.com Redirect "/" "https://www.memoriesgameseries.com/" </VirtualHost> Listen 443 <VirtualHos
IncludeOptional conf.d/*.conf
<VirtualHost *:80>
ServerName www.memoriesgameseries.com
Redirect "/" "https://www.memoriesgameseries.com/"
</VirtualHost>
Listen 443
<VirtualHost *:443>
ServerName www.memoriesgameseries.com
SSLEngine on
SSLCertificateFile "/etc/httpd/memoriesgameseries_com.crt"
SSLCACertificateFile "/etc/httpd/memoriesgameseries_com.ca-bundle"
SSLCertificateKeyFile "/etc/httpd/memoriesgameseries.com.key"
</VirtualHost>
但是,每当我试图通过http而不是正确重定向访问网站时,当我键入根地址时,例如www.memoriesgameseries.com
和http://memoriesgameseries
重定向根本无法启动。当我在根域上方键入URL时,例如http://memoriesgameseries.com/memories
重定向开始生效,我在浏览器中看到https URL(例如https://www.memoriesgameseries.com/memories
),但我得到了:
找不到
在此服务器上找不到请求的URL/内存
来自服务器的响应。什么可能导致此问题?关键是服务器正在尝试管理404。那不是生活,让SPA为你做吧 当404重定向到index.html时
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
不幸的是,此代码导致了冲突:
拒绝执行内联脚本,因为它违反了以下内容安全策略指令:script src“self”[etc]
我忘了将其添加到服务器文件夹根目录下的.htaccess文件中。我在Fedora上,因此它使用/etc/httpd/conf/httpd.conf
而不是.htaccess
。我将建议的代码添加到httpd.conf
文件中,导致内容安全策略冲突错误。我还尝试了重定向永久/https://www.memoriesgameseries.com/
这会导致浏览器中出现过多重定向错误。
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html