Search by

skeeks / yii2-external-links

skeeks-semenov

AutoCorrect external links after rendering html page

Package info

github.com/skeeks-semenov/yii2-external-links

Homepage

Issues

Wiki

Type:yii2-extension

pkg:composer/skeeks/yii2-external-links

Statistics

Installs: 3 152

Dependents: 1

Suggesters: 0

Stars: 4

1.2.0 2026-10-26 10:32 UTC

This package is auto-updated.

Last update: 2026-10-26 10:35:54 UTC


README

Latest Stable Version Total Downloads

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist skeeks/yii2-external-links "*"

or add

"skeeks/yii2-external-links": "*"

How to use (simple)

//App config
[
    'bootstrap'    => ['externalLinks'],

    'components'    =>
    [
        //....
        'externalLinks' =>
        [
            'class' => 'skeeks\yii2\externalLinks\ExternalLinksComponent',
        ],
        //....
    ],

    'modules'    =>
    [
        //....
        'externallinks' =>
        [
            'class' => 'skeeks\yii2\externalLinks\ExternalLinksModule',
        ],
        //....
    ]
]

How to use (advanced)

//App config
[
    'bootstrap'    => ['externalLinks'],

    'components'    =>
    [
        //....
        'externalLinks' =>
        [
            'class' => 'skeeks\yii2\externalLinks\ExternalLinksComponent',

            //Additional
            'enabled'                           => true,
            'noReplaceLocalDomain'              => true,
            'backendRoute'                      => '/externallinks/redirect/redirect',
            'backendRouteParam'                 => 'url',
            'enabledB64Encode'                  => true,
            'noReplaceLinksOnDomains'           => [
                'site1.ru',
                'www.site1.ru',
                'site2.ru',
            ],
        ],
        
        'urlManager' => 
        [
            'rules' => 
            [
                //Rewriting the standard route
                '~skeeks-redirect'                        => '/externallinks/redirect/redirect',
            ]
        ]
        //....
    ],

    'modules'    =>
    [
        //....
        'externallinks' =>
        [
            'class' => 'skeeks\yii2\externalLinks\ExternalLinksModule',
        ],
        //....
    ]
]

Redirect page security

  • Only absolute links with a scheme from allowedSchemes (http, https by default) are accepted; anything else gets 400.
  • Links replaced on the page are signed: createRedirectUrl($url) adds the signParam (sign) parameter, an HMAC of the link with signKey (the request cookieValidationKey by default). Signed links are opened automatically.
  • Unsigned or wrongly signed links (old caches, search engines, links made by somebody else) are not opened automatically: the page shows the target address and a "go" button.
  • The page is sent with X-Robots-Tag: noindex, nofollow and the robots meta tag. Do not disallow it in robots.txt, otherwise search engines cannot see noindex.

##Screenshot SkeekS CMS admin panel

skeeks!
SkeekS CMS (Yii2) — quickly, easily and effectively!
skeeks.com | cms.skeeks.com