Support » Fixing WordPress » Request for media file at root checking existence in wp-content/uploads

  • Hi all – anyone know if there’s a plugin that will work a bit like this…

    A whole load of media files in wp-content/uploads already: a mix of PDFs, JPGs, PNGs. Let’s for example say 1.pdf, 2.jpg, 3.png but there are thousands with a mix of filenames with no pattern.

    User goes too www.website.com/1.pdf which doesn’t exist so would ordinarily 404, but before 404ing plugin check for www.website.com/wp-contents/uploads/1.pdf and if it exist, displays that (ideally re-writing the URL to www.website.com/1.pdf but that’s less important). If it doesn’t exist, it 404s as per normal.

    Thanks in advance.
    Ed

Viewing 3 replies - 1 through 3 (of 3 total)
  • There might be, but not the rewrite part. WordPress already handles media with a URL as you are suggesting, however, it is only applicable to media that is not attached to any post. If it is attached, the permalink for the media contains the post type and the post name and then the media name. You can see this by going to the Media Library and looking at the URL for the View links (easiest in list mode instead of grid mode).

    Thread Starter edludlow

    (@edludlow)

    Hi all – just brining this back to the top. Jo @joyously’s post above, I expected to be able to upload a media file (let’s call it picture.jpg) and be able to access at http://www.domain.com/picture.jpg assuming it wasn’t attached to a post. But this isn’t working for me on numerous WP installs.

    Have I misunderstood? If there’s a way of achieving that sort of functionality I’d be very keen to know how it’s done.

    Thank!

    Thread Starter edludlow

    (@edludlow)

    Just to close this, I’ve worked around this myself by adding a check using file_exists() in my 404.php file. If the file exists at wp-content/uploads/ it will now redirect to that.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Request for media file at root checking existence in wp-content/uploads’ is closed to new replies.