Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Angular和Apache从http重定向到https不工作_Apache_Angular_Redirect_Https_Routing - Fatal编程技术网

使用Angular和Apache从http重定向到https不工作

使用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

我安装了SSL证书,我想将所有流量从http重定向到https。我已将此部分添加到Apache服务器:

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