正如你所说的,SilverStripe 有路由,它们可以在 yaml 配置文件中定义。
如果您查看routes.yml框架中的现有内容,您可以看到默认安全路由是如何定义的:
 https ://github.com/silverstripe/silverstripe-framework/blob/fd6a1619cb7696d0f7e3ab344bc5ac7d9f6cfe77/_config/routes.yml#L17
如果您只想替换Secuirtyin ,只需使用以下内容Secuirty/login创建您自己的routes.ymlin即可:mysite/_config/
---
Name: myroutesorsomeotherrandomname
Before: '*'
After:
  - '#rootroutes'
  - '#coreroutes'
  - '#modelascontrollerroutes'
  - '#adminroutes'
---
Director:
  rules:
    'foobar//$Action/$ID/$OtherID': 'Security'
注意:确保运行 ?flush=1 以确保加载 yml 文件(它们被缓存)
还确保在 yml 文件中使用空格,如果您使用制表符,您将度过一段糟糕的时光
但是,如果您还希望替换/login,并且/logout这不再是路由的事情。
login 和 logout 是 on Security 上的操作(在 Security::$allowed_actions 中列出的 php 函数,因此可用作 URL)。
但它仍然相当简单,只需子类 Security 并创建您想要的操作:
<?php
class MySuperSecurity extends Security {
    private static $allowed_actions = array(
        'showMeTheLoginForm',
        'alternative_login_action_with_dashes',
        'doTheLogout',
    );
    function showMeTheLoginForm() {
        // can be visited via http://website.com/foobar/showMeTheLoginForm
        return $this->login();
    }
    function alternative_login_action_with_dashes() {
        // can be visited via http://website.com/foobar/alternative-login-action-with-dashes
        return $this->login();
    }
    function doTheLogout($redirect = true) {
        // can be visited via http://website.com/foobar/doTheLogout
        return $this->logout($redirect);
    }
}
并使路由指向您的新类而不是 Security 内routes.yml:
    'foobar//$Action/$ID/$OtherID': 'MySuperSecurity'
注意:再次确保您执行了 ?flush=1,private static $allowed_actions以及 yml 配置文件都由 silverstripe 缓存。
注意:这篇文章中建议的两种解决方案都将创建一个额外的登录路径,并且不会替换现有的路径,因此旧的Security/login仍然可用