Support » Fixing WordPress » [Plugin: WordPress Download Monitor] Help: Plugin does not work if the WordPress URL and the Blog UR

  • Hey there,

    First of all I would like to thank Mike, the developer of the WordPress Download Monitor plugin, for the work he has put into it. I use it on my personal blog and it works like a charm.

    The problem is I’m also using it on a website that, unlike my personal blog, does not have the WordPress files on the same URL as the blog address.

    The website is on the root (ex.: ), and the WordPress files are in a separate directory (ex.: ).

    When I place the shortcode of a download in the editor and go check out the page, the download url is something like (I’ve set up nice urls and updated the .htaccess file), I get the 404 page. Shouldn’t that nice url ommit the WordPress directory? I don’t know…

    Has anyone encountered a problem like this or is it just me??

    I’ve tried the same thing on another website I have with a similar setup and the problem persisted.

    As I said, on my personal blog (that has all the WordPress files on the root) it works like a charm.

    Please please please help me out!

    Take care,

Viewing 3 replies - 1 through 3 (of 3 total)
  • I have the same problem. Any ideas?

    I looked into the code and it is a pretty simple fix. The problem is that the RewriteRule being output to .htaccess assumes the wordpress URL is the URL where the wordpress files reside themselves. In my case (and yours it sounds like) we have our root directory serve wordpress files located in a subfolder (named ‘wp’ in my case). The incorrect RewriteRule which is currently generated is (assuming the pretty permalink url is ‘files’):

    RewriteRule ^files/(.*)$ wp-content/plugins/download-monitor/download.php?id=$1 [L]

    The correct rule for a wordpress installation in the ‘wp’ folder should be:

    RewriteRule ^wp/files/(.*)$ wp/wp-content/plugins/download-monitor/download.php?id=$1 [L]

    And finally, Mike could probably write something more elegant, but here is a temporary patch to fix the code:

    --- original/download-monitor/wp-download_monitor.php
    +++ fixed/download-monitor/wp-download_monitor.php
    @@ -1823,11 +1823,16 @@
     function wp_dlm_rewrite($rewrite) {
                    $url = get_option('wp_dlm_url');
                    $blog = get_bloginfo('wpurl');
    +               $base_url = get_bloginfo('url');
    +               if(strlen($blog) > strlen($base_url))
    +                       $offset = substr(str_replace($base_url, '', $blog), 1) . '/';
    +               else
    +                       $offset = '';
                    $rule = ('
     Options +FollowSymLinks
     RewriteEngine on
    -RewriteRule ^'.$url.'(.*)$ wp-content/plugins/download-monitor/download.php?id=$1 [L]
    +RewriteRule ^' . $offset . $url . '(.*)$ ' . $offset . 'wp-content/plugins/download-monitor/download.php?id=$1 [L]
                    return $rule.$rewrite;

    David Underhill



    Thanks Dave 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WordPress Download Monitor] Help: Plugin does not work if the WordPress URL and the Blog UR’ is closed to new replies.