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.

Revisions

  1. abdulawal39 created this gist Dec 3, 2025.
    17 changes: 17 additions & 0 deletions custom-redirects.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    /**
    * 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;
    }