Last active
March 5, 2024 19:15
-
-
Save timkelty/838d98c315133fedef4574e3a1028a9e to your computer and use it in GitHub Desktop.
Redirect wp-content to Cloud assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Site URL Rules | |
* | |
* You can define custom site URL rules here, which Craft will check in addition | |
* to routes defined in Settings → Routes. | |
* | |
* Read all about Craft’s routing behavior, here: | |
* https://craftcms.com/docs/4.x/routing.html | |
*/ | |
return [ | |
'<uri:wp-content/uploads/.*>' => [ | |
'route' => 'redirect', | |
'params' => [ | |
'url' => Craft::$app->getSecurity()->hashData( | |
(new \craft\cloud\fs\AssetsFs())->createUrl( | |
Craft::$app->getRequest()->getPathInfo() | |
) | |
), | |
'statusCode' => 301, | |
], | |
], | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment