skeeks / yii2-external-links
AutoCorrect external links after rendering html page
Package info
github.com/skeeks-semenov/yii2-external-links
Type:yii2-extension
pkg:composer/skeeks/yii2-external-links
1.2.0
2026-10-26 10:32 UTC
Requires
- yiisoft/yii2: ~2.0.13
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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,httpsby default) are accepted; anything else gets 400. - Links replaced on the page are signed:
createRedirectUrl($url)adds thesignParam(sign) parameter, an HMAC of the link withsignKey(the requestcookieValidationKeyby 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, nofollowand the robots meta tag. Do not disallow it in robots.txt, otherwise search engines cannot see noindex.
SkeekS CMS (Yii2) — quickly, easily and effectively!
skeeks.com | cms.skeeks.com