在SilverStripe 3.1.x中-是否可以设置安全的baseURL?

在mysite / _config.php中,我具有以下内容:

Director::forceSSL(array('/^admin/', '/^Security/'));


当访问包含“ admin”或“ Security”的URL时,SilverStripe使用https,这对于为自己的域购买了安全证书的人们来说非常有用。但是,对于在共享托管平台上使用共享SSL的用户,站点的基本安全URL可能会完全不同。

因此,虽然非安全的基本URL可能是
http://www.example.com/

安全的基本URL可能是https://123.45.67.89/example.com/

我将如何强制将SSL用于“管理员”和“安全性”,以及如何指定基本安全URL,这是某些使用基本共享SSL证书的主机所需要的?

最佳答案

您不能使用URLRewriting吗?任何HTTPS请求都会重定向到正确的域...

例如对于Apache,取自https://github.com/h5bp/server-configs-apache

# Rewrite secure requests properly in order to prevent SSL certificate warnings.
# E.g.: prevent `https://www.example.com` when your certificate only allows
# `https://secure.example.com`.

# <IfModule mod_rewrite.c>
#     RewriteCond %{SERVER_PORT} !^443
#     RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L]
# </IfModule>

10-02 04:24