• Resolved mat-Moo

    (@mat-moo)


    I’m using Permalink Manager to manage all my page url structure (for compatibility with old website), however no matter what I do I get a 404 on the download links (tried this sticky no difference).

    When the code gets to the function simple_download_counter_download_handler the $_GET request only contains the query param “key” and nothing else.

    I can fix it by also checking the REQUEST URI to grab the parameter needed… thoughts?

     if (isset($_GET[$key]) && !empty($_GET[$key])) {
    
                $wp->query_vars[$key] = sanitize_key($_GET[$key]);
        } else {
                $uri_segments = explode('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
                if ((count($uri_segments) > 3) && ($uri_segments[1] == $key)) {
                    $wp->query_vars[$key] = sanitize_key($uri_segments[2]);
                }
        }
Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Jeff Starr

    (@specialk)

    Very interesting, thank you for reporting. Can you let me know the following:

    • Version of PHP
    • Linux or Windows or other server
    Thread Starter mat-Moo

    (@mat-moo)

    PHP 8.3.1
    AlmaLinux v9.3.0

    I think permalink is a red herring TBH – also latest version of wordpress

    Plugin Author Jeff Starr

    (@specialk)

    Apache, Nginx, or..?

    Thread Starter mat-Moo

    (@mat-moo)

    Apache (Sorry I swore I replied!) – Have my own server running WHM/cPanel

    Plugin Author Jeff Starr

    (@specialk)

    Thanks. And have you tried testing on default WP install? (default settings, default theme, and no other plugins) That will help narrow down possible factors.

    Thread Starter mat-Moo

    (@mat-moo)

    Hmmm blank install the perm url looks like
    /?sdc_download=6&key=wx7uxx79iyxx6rp9ud1m8tv0jhu4p5
    But on my install its showing as
    /sdc_download/259/?key=nh8bgg5t8e8of17qx82tz5713ou4bf
    Which explains why it’s not working – so something is url rewriting?

    Plugin Author Jeff Starr

    (@specialk)

    Are permalinks enabled on site? It looks like the difference between WP’s regular (query string) URLs and the fancy permalink URLs.

    Thread Starter mat-Moo

    (@mat-moo)

    (I’m new to WP) I’m using a custom structure for the permastructure, but using the Pemalink Manager Lite for custom page ULRS

    Plugin Author Jeff Starr

    (@specialk)

    Yeah that might have something to do with it. Does SDC work when the permalink manager plugin is *not* active?

    Thread Starter mat-Moo

    (@mat-moo)

    No I deactivated it to test, and was still the same, been trying all the plugins – And it is the Permalink structure – as soon as I use custom structure it breaks (unless I use my fix)

    Plugin Author Jeff Starr

    (@specialk)

    Hmm.. what is the custom structure, so I can visit Permalinks settings and enter the same thing.

    Thread Starter mat-Moo

    (@mat-moo)

    Not sure it matters, but using custom with

    /%year%/%monthnum%/%day%/

    Thread Starter mat-Moo

    (@mat-moo)

    Which made me thank that while my code works, if you change that it would break the code as well…

    Plugin Author Jeff Starr

    (@specialk)

    Ok so now I am confused, first you say this:

    “as soon as I use custom structure it breaks”

    ..which implies the issue is with the custom permalinks. So then I ask for the custom structure, and you say:

    “Not sure it matters, but using custom..”

    Does the custom permalink structure have anything to do with the reported issue?

    Remember the goal of troubleshooting is to eliminate variables. So if something (like permalink structure) is *not* involved, then we scratch it off the list and try something else.

    • This reply was modified 10 months ago by Jeff Starr.
    • This reply was modified 10 months ago by Jeff Starr.
    Thread Starter mat-Moo

    (@mat-moo)

    Why are you confused? I have gone to my permalinks options, selected custom structure (/wp-admin/options-permalink.php) – it breaks

    When I said it doesn’t matter, in terms of what options you put in the custom structure.

    Please don’t try and preach debugging code to me ?? I am trying to help you

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘404 no matter what, compatibility issue?’ is closed to new replies.