Support » Fixing WordPress » Everything rewrites to index.php – how can I setup files for users to download?

  • How do you allow downloads of a file with WordPress setup in the root directory? If I want someone to download http://www.abc.com/file.zip but my WP2 is setup in the root of the site, it keeps redirecting to the homepage…

    It seems like I need to setup a mod_rewrite exception or something for the files? How would you do this? Ideally I could setup just 1 folder and put anything to be excepted from mod_rewrite in there.

    My permalink structure is pretty basic: /%post_id%

    Here’s my .htaccess

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter mdolan

    (@mdolan)

    No ideas on how I can fix this?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    You don’t need to fix anything. It should just work. See these two lines?

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    The first one makes the redirection stop when the file actually exists. Without this, you would not be able to get images or css files or anything other than index.php to show up on your page.

    The second one does the same thing, but for subdirectories.

    Anyway, all you have to do is to upload file.zip and create the proper link to it. That’s it. If the link does not work, you either named the file wrong or made the link wrong. Redirection only occurs when the link points to something that does not actually exist on the website.

    Thread Starter mdolan

    (@mdolan)

    That’s my problem though – even though the redirect looks correct, even when I upload something into the root dir as simple as “abc.zip” and like to url.com/abc.zip it doesn’t work… sends you to the url.com/index.php i can’t figure out what else would be causing this.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    The only thing I can think of is that you’re putting the file in the wrong place. Given that your blog works and presumably has images and CSS and such, then that part of the htaccess rules is working (like I said, without it, the results are fairly catastrophic).

    This abc.zip file, it is in the same directory as your main blog’s index.php and wp-config.php, yesno? Or is it in the “root” directory and then you have the blog in a different directory? If so, what’s the .htaccess in the root directory look like?

    Thread Starter mdolan

    (@mdolan)

    that is the .htaccess in the root dir. the config.php file is in the same root as well. And it was working at some point (lost track of when it broke).

    The website root dir looks like this:

    .
    ..
    config.php
    index.php
    .htaccess
    abc.zip
    wp-folders/

    Thread Starter mdolan

    (@mdolan)

    by the way, if I add a folder say url.com/test/abc.zip, the same thing happens… this is crazy. Is there a chance the .htaccess file is cached or something?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Okay, I’m confused.. Do you have the blog in a subdirectory called wp-folders? Where’s the “wp-config.php” file? Not “config.php”.

    Details matter.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Everything rewrites to index.php – how can I setup files for users to download?’ is closed to new replies.