在 SilverStripe 管理中强制保存小写 URL
Force saving a lowercase URL in the SilverStripe admin
出于 SEO 目的,我需要确保所有 URL 都保存为小写。
如何强制 SilverStripe 管理员将 URL 保存为小写,即使用户以大写输入永久链接?
您可以在 Page
的 onBeforeWrite
方法中执行此操作:
protected function onBeforeWrite() {
parent::onBeforeWrite(); //this is important!
$this->URLSegment = strtolower($this->URLSegment);
}
出于 SEO 目的,我需要确保所有 URL 都保存为小写。
如何强制 SilverStripe 管理员将 URL 保存为小写,即使用户以大写输入永久链接?
您可以在 Page
的 onBeforeWrite
方法中执行此操作:
protected function onBeforeWrite() {
parent::onBeforeWrite(); //this is important!
$this->URLSegment = strtolower($this->URLSegment);
}