Broken Download Links Fixed

I had an issue where all of the download links on the site were broke. I have no idea how long this has been an issue because it all worked fine when I first set the website up.

First, I discovered that WordPress had put any of the files I “recently” uploaded in the wrong place. By default, WordPress is supposed to look in the path INSTALL_DIR/wp-content/uploads for uploaded content. However, I looked at the source code to find that you can override this behavior with a setting in the database. Somehow, that had happened to me. I deleted the record from the database and tried again.

I was still getting 404 when I moved the files to the right location! What was strange was that these were WordPress 404 errors, not Apache. I deleted my “.htaccess” file and refreshed the page after clearing my browser cache. Direct links to the files worked, but obviously the rest of the site was broken.

To fix the .htaccess file I restored what I had, ran “chmod 666 .htaccess”, then went into the WP admin -> Settings -> Permalink Settings and changed the permalink setting, hit apply, then changed it back and hit apply again. This (presumably) forced WP to rebuild my .htaccess file.

All is now well again.

One comment

Leave a Comment