Skip to content

Instantly share code, notes, and snippets.

@abdulawal39
Created December 3, 2025 13:04
Show Gist options
  • Select an option

  • Save abdulawal39/0217e27ecbed359394948e231d8902c0 to your computer and use it in GitHub Desktop.

Select an option

Save abdulawal39/0217e27ecbed359394948e231d8902c0 to your computer and use it in GitHub Desktop.
Custom redirection php code for WFAM
/**
* Custom Redirects for WFAM
*/
$request_uri = $_SERVER['REQUEST_URI'];
$request_path = strtok($request_uri, '?');
// Match: /wp-content/uploads/anything.extension
if (preg_match('#^/wp-content/uploads(/.*\.\w+)$#', $request_path, $matches)) {
// Set the query parameter
$_GET['wfam_requested_file'] = $matches[1];
$_REQUEST['wfam_requested_file'] = $matches[1];
// Include WordPress
require_once(__DIR__ . '/index.php');
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment