We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21101
    • 169 Posts
    i have a problem too with the RewriteRule

    my urls are like that:
    [tt]http://www.mysite.com/en/Files [/tt]
    [tt]http://www.mysite.com/en/Contact [/tt]
    [tt]http://www.mysite.com/en/Our_Products/Product1 [/tt]
    (i have removed the .html suffix in the modx system configuration)

    when i disable Friendly urls, all works fine smiley

    but when it is enabled, my url processed with FileDownload 2.5 + FileDownloadPlugin 1.1 are something like that
    [tt]http://www.mysite.com/en/Downloads/my_file.exe[/tt] and of course, the file is not found grin

    any idea ?
    thanks smiley
      Play no games
      • 31979
      • 26 Posts
      Using FileDownload 2.5 + FileDownloadPlugin 1.1 and Safari the binary data of pdf documents is opened in the browser window. huh
        www.waso.com
        • 22279
        • 10 Posts
        Quote from: Marturion at Jan 05, 2007, 12:39 PM
        It appears that the FileDownloadPlugin doesn’t like the character "+" (and others?) in the downloadable file’s name. It doesn’t download, the page just refreshes. is there a way to add support for weird special characters in the filenames?
        I believe "+" (plus sign) it being converted into " " (space) when URL decoding by PHP. Therefore I think you need to URL encode + sign like:
        http://www.mymodxsite.com/download.html/file%2Bwith%2Bplus.zip
        rather than:
        http://www.mymodxsite.com/download.html/file+with+plus.zip

        Quote from: Marturion at Jan 05, 2007, 12:39 PM
        Also, if i reference a TV as part of the path specified in the FileDownloadFolder TV ( example: assets/files/[*TV*] ) i get a parse error.
        I’m not sure if you can do so. I need to have a look at MODx CMS reference to see if on TV can reference other TVs in its body. Probably I would need to call other MODx API function than the one getting plain TV variable, so I got some evaluation.
          • 18503
          • 45 Posts
          Great, thanks for the reply. I don’t think the TV will reference the way I was hoping. It appears that when the path is needed by the FileDownloadPlugin, the TV hasn’t parsed out yet (just guessing here).

          I found that if i reference [*TV1*] in [*TV2*] and place [*TV2*] on a page, it displays the content of [*TV1*]. So for output purposes it looks like a TV can hold another TV, but this parsing must happen sometime after the plugins are parsed. I ended up solving my particular problem by having the path get created and placed in the FileDownloadFolder TV during a different process, which isn’t quite as dynamic, but should work great for my purposes.

          I’ll check into the special character problem some more, thanks for the idea about URL encoding.

          Edit:
          In the URL, i replaced the "+" with "%2B" to test if URL encoding would help, but it still just refreshed the page, it didn’t start the download.
            -dan
            http://wylio.com
            Wylio - Pictures for Bloggers
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: negz at Jan 09, 2007, 07:40 AM

            i have a problem too with the RewriteRule

            my urls are like that:
            [tt]http://www.mysite.com/en/Files [/tt]
            [tt]http://www.mysite.com/en/Contact [/tt]
            [tt]http://www.mysite.com/en/Our_Products/Product1 [/tt]
            (i have removed the .html suffix in the modx system configuration)

            when i disable Friendly urls, all works fine smiley

            but when it is enabled, my url processed with FileDownload 2.5 + FileDownloadPlugin 1.1 are something like that
            [tt]http://www.mysite.com/en/Downloads/my_file.exe[/tt] and of course, the file is not found grin

            any idea ?
            thanks smiley
            Same problem here...it appears the FileDownload class creates the URL’s with a / instead of & if friendly urls are enabled. And there does not appear to be a way to control this in the snippet parameters...I’ve modified mine to remove this logic and generate it the same either way and it works fine.

            Change lines 340-344 of filedownload.class.inc.php:
            //					if ($this->_config['urlsetting'] == '?') {
            //						$fileLink = $this->_config['curUrl'].'/'.$filelocat . $multiFolderLink;
            //					} else {
            						$fileLink = $this->_config['curUrl'].'&d='.$filelocat . $multiFolderLink;
            //					}


            The variation with the / only works if you change your .htaccess as described in the FileDownloadPlugin instructions.
              • 18503
              • 45 Posts
              Thanks OpenGeek, But for some reason i’m still having trouble. I tried commenting out the lines of code you suggested (with each possible variation of the 2 different rewrite rules in .htaccess, and each choice un-commented) but I still just get a page refresh instead of the file if it has a "+" in the file name (even if i change it to %2B in the URL instead of the "+").

              Thanks again, any other ideas?
                -dan
                http://wylio.com
                Wylio - Pictures for Bloggers
                • 22279
                • 10 Posts
                Quote from: negz at Jan 09, 2007, 07:40 AM

                but when it is enabled, my url processed with FileDownload 2.5 + FileDownloadPlugin 1.1 are something like that
                [tt]http://www.mysite.com/en/Downloads/my_file.exe[/tt] and of course, the file is not found grin
                The rewrite rule
                RewriteRule ^([^/]*)/?(.*)$ index.php?q=$1&d=$2 [L,QSA]
                is for plain file structure so it will not work because it seeks for:
                [tt][*TV*]/Downloads/my_file.exe[/tt] from the document [tt]http://www.mysite.com/en[/tt]

                What you want is probably:
                RewriteRule ^(.*?)/?([^/]*)$ index.php?q=$1&d=$2 [L,QSA]
                but this will interpret always last chunk after [tt]/[/tt] as a file to download.. therefore invalid.

                I must admit that indeed it cannot work with non-flat friendly URLs Use friendly alias path: Yes, since you cannot find out the point of division between document alias and filename.

                I’m adding a Warning about this into the plugin’s documentation. Sorry for that.

                I’m gonna also inform the author of FileDownload snippet to enable friendly URLs only when structure is flat.
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Hmmm, ok, but it works fine with my changes alongside the default MODx rewrite rules, as seen here http://xpdo.org/download-alpha.html ...
                    • 18503
                    • 45 Posts
                    OpenGeek, have you tried a file that has a "+" in the name? I don’t think I’ve experienced the problem with a "-".
                      -dan
                      http://wylio.com
                      Wylio - Pictures for Bloggers
                      • 22303 MODX Staff
                      • 10,725 Posts
                      A plus sign equals a space in a URL. That likely needs to be urlencoded if it’s an actual plus sign and not a space.