我正在express.js
Apache服务器后面运行应用程序,方法是对应用程序端口的简单重写:
RewriteEngine On
RewriteRule ^(.*) http://localhost:61987/$1 [P]
这按预期工作。
由于该应用程序有望很快上线,因此我也尝试通过RewriteRule
s添加强制SSL连接。我在预节点(即PHP)时代做到这一点的方式是:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} != on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301, L]
RewriteRule ^(.*) http://localhost:61987/$1 [P]
但是,结合到我的Express应用程序的路由,这给了我500 Internal Server错误。
处理此设置的正确方法是什么?
您在L
中有一个空格[R=301, L]
。
试试这个代码:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^ http://localhost:61987%{REQUEST_URI} [P]
假设node.js
服务器61987
也支持https
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句