Skip to content

Instantly share code, notes, and snippets.

@timkelty
Last active March 5, 2024 19:15
Show Gist options
  • Save timkelty/838d98c315133fedef4574e3a1028a9e to your computer and use it in GitHub Desktop.
Save timkelty/838d98c315133fedef4574e3a1028a9e to your computer and use it in GitHub Desktop.
Redirect wp-content to Cloud assets
<?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