承接 fromholdio/silverstripe-superlinker-redirection 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fromholdio/silverstripe-superlinker-redirection

Composer 安装命令:

composer require fromholdio/silverstripe-superlinker-redirection

包简介

Replace for OOTB Silverstripe Redirector Page, using a SuperLink target to select a much wider range of target types

README 文档

README

Advanced redirector pages and standalone redirects using SuperLink targets.

Overview

Replaces SilverStripe's built-in RedirectorPage with a more powerful system that:

  • Supports all SuperLink types (not just internal/external)
  • Provides standalone Redirection DataObjects
  • Offers HTTP status code selection
  • Includes collision detection
  • Supports custom URL paths

Requirements

  • SilverStripe CMS ^6.0
  • fromholdio/silverstripe-superlinker ^4.0.0
  • fromholdio/silverstripe-relativeurlfield ^2.0.0
  • fromholdio/silverstripe-hidden-pages ^3.0.0
  • fromholdio/silverstripe-hasoneedit ^3.0.1

Installation

composer require fromholdio/silverstripe-superlinker-redirection

Run dev/build:

vendor/bin/sake dev/build flush=1

Features

RedirectionPage

A page type that redirects to any SuperLink target.

Features:

  • Redirect to any link type (SiteTree, External, Email, File, System, etc.)
  • HTTP status code selection (301, 302, 303, 307, 308)
  • Hidden from site tree by default
  • Automatic redirect on page load

Usage:

$redirector = RedirectionPage::create();
$redirector->Title = 'Old Product Page';
$redirector->URLSegment = 'old-product';
$redirector->write();

// Set redirect target
$redirector->RedirectLink()->LinkType = 'sitetree';
$redirector->RedirectLink()->SiteTreeID = $newPage->ID;
$redirector->RedirectLink()->write();

$redirector->publishRecursive();

Redirection DataObject

Standalone redirects not tied to pages.

Features:

  • Redirect from custom URL paths
  • Collision detection with site tree
  • HTTP status code selection
  • Admin interface for management

Usage:

$redirect = Redirection::create();
$redirect->FromURL = '/old-path';
$redirect->StatusCode = 301;
$redirect->write();

// Set redirect target
$redirect->RedirectLink()->LinkType = 'external';
$redirect->RedirectLink()->ExternalURL = 'https://example.com/new-path';
$redirect->RedirectLink()->write();

Configuration

HTTP Status Codes

Available status codes:

  • 301 - Moved Permanently (default for SEO)
  • 302 - Found (temporary redirect)
  • 303 - See Other
  • 307 - Temporary Redirect (preserves method)
  • 308 - Permanent Redirect (preserves method)

Hiding RedirectionPage from Site Tree

Fromholdio\SuperLinkerRedirection\Pages\RedirectionPage:
  hide_from_hierarchy: true
  hide_from_cms_menu: false

Force redirections over live pages

By default a RedirectionSuperLink fires only as a 404 fallback: if a published page already exists at the redirection's origin URL, that page is served and the redirect never runs.

Set do_force_redirections to make redirections take precedence over the site tree — a matching redirect then fires even when a live page exists at the URL, checked in onBeforeInit before the page controller renders (comparable to Misdirection's enforce mode):

Fromholdio\SuperLinkerRedirection\Model\RedirectionSuperLink:
  do_force_redirections: true
  • Default is false — the original 404-fallback behaviour is unchanged.
  • Reserved paths in disallowed_redirect_origin_url_paths (/admin, /dev, …) are never redirected.
  • Site/host scoping still applies: the check runs in controller context and invokes the updateRedirectionsFilter extension hook, so any multisite SiteID narrowing works the same as in fallback mode.
  • Force mode queries RedirectionFromRelativeURL on every request; it's indexed on the model — run dev/build after upgrading.

Usage Examples

Example 1: Redirect Old Page to New Page

$redirector = RedirectionPage::create([
    'Title' => 'Old About Page',
    'URLSegment' => 'old-about'
]);
$redirector->write();

$redirector->RedirectLink()->LinkType = 'sitetree';
$redirector->RedirectLink()->SiteTreeID = $newAboutPage->ID;
$redirector->RedirectLink()->write();

$redirector->publishRecursive();

Example 2: Redirect to External Site

$redirector = RedirectionPage::create([
    'Title' => 'External Resource',
    'URLSegment' => 'external-resource'
]);
$redirector->write();

$redirector->RedirectLink()->LinkType = 'external';
$redirector->RedirectLink()->ExternalURL = 'https://external-site.com/resource';
$redirector->RedirectLink()->write();

$redirector->publishRecursive();

Example 3: Redirect to File Download

$redirector = RedirectionPage::create([
    'Title' => 'Download Brochure',
    'URLSegment' => 'brochure'
]);
$redirector->write();

$redirector->RedirectLink()->LinkType = 'file';
$redirector->RedirectLink()->FileID = $brochureFile->ID;
$redirector->RedirectLink()->write();

$redirector->publishRecursive();

Example 4: Standalone Redirect

$redirect = Redirection::create([
    'FromURL' => '/old-blog/2020/article',
    'StatusCode' => 301
]);
$redirect->write();

$redirect->RedirectLink()->LinkType = 'sitetree';
$redirect->RedirectLink()->SiteTreeID = $newArticlePage->ID;
$redirect->RedirectLink()->write();

Admin Interface

Redirections can be managed through the CMS:

  1. Navigate to the Redirections admin
  2. Add new redirections
  3. Set source URL and target link
  4. Choose HTTP status code
  5. Save

Migration from RedirectorPage

To migrate existing RedirectorPage instances:

use SilverStripe\CMS\Model\RedirectorPage as CoreRedirectorPage;
use Fromholdio\SuperLinkerRedirection\Pages\RedirectionPage;

// Get all core redirector pages
$oldRedirectors = CoreRedirectorPage::get();

foreach ($oldRedirectors as $old) {
    $new = RedirectionPage::create([
        'Title' => $old->Title,
        'URLSegment' => $old->URLSegment,
        'ParentID' => $old->ParentID
    ]);
    $new->write();

    // Migrate redirect target
    if ($old->RedirectionType === 'Internal') {
        $new->RedirectLink()->LinkType = 'sitetree';
        $new->RedirectLink()->SiteTreeID = $old->LinkToID;
    } else {
        $new->RedirectLink()->LinkType = 'external';
        $new->RedirectLink()->ExternalURL = $old->ExternalURL;
    }
    $new->RedirectLink()->write();

    $new->publishRecursive();
    $old->doArchive();
}

Known Issues & Todos

  • Validation improvements needed
  • File has-many redirects field
  • Site tree has-many redirects field improvements
  • Proper i18n/translations
  • Link tracking/syncing

Documentation

For complete SuperLinker documentation, see:

License

BSD-3-Clause

Support

fromholdio/silverstripe-superlinker-redirection 适用场景与选型建议

fromholdio/silverstripe-superlinker-redirection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.27k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「link」 「silverstripe」 「redirection」 「redirects」 「superlinker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fromholdio/silverstripe-superlinker-redirection 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fromholdio/silverstripe-superlinker-redirection 我们能提供哪些服务?
定制开发 / 二次开发

基于 fromholdio/silverstripe-superlinker-redirection 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.27k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 15
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-07-19