If you really want to use PHP, you’d have to do some sort of redirect for URLs to /uploads/
to a handler script. Depending on how many of these situations you have, it may be easier/simpler to create a redirect for each file; could potentially be done on upload, interfacing with a plugin like Redirection.
Related Posts:
- How do I make a redirect in PHP?
- Disable Attachment Pages Completely
- How to add a class to the attachment images
- PHP – redirect https to http and www to non-www
- Redirect to Page after Post Submit
- How to redirect users to custom lostpassword page?
- Adding Featured Image to Post programatically
- Add custom field to attachments in a specific category
- Conditional Statement – check if post has an attachment image
- Upload images and attachments from frontend form
- Insert code when users come from an specific referer
- How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
- Is Auto Post recognition a WordPress feature? How to turn it off?
- Get a Page’s attachments in Gallery order
- Use Timber/Twig to pull an image by image ID [closed]
- WordPress template_include filter not working properly
- Logout and redirect using the WP Menu
- File upload, uploads only file name
- Change links automatically to affiliate links
- page template for attachement page?
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- PHP If user is logged in & on home page redirect
- Link to the parent post in attachment page
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- WordPress does not load page.php, return 404.php
- WordPress Search Results for Multiple Post Types
- 3 blogs same installation, without WP MU
- WordPress homepage infinite redirect
- Redirect undesirable domain
- Send multiple attachments with wp_mail in PHP
- How do I display the main domain for my WordPress install?
- Attach previously uploaded image to post – current code has unexpected results
- Problem with login form
- Set Cache-Control header for 301 redirects
- How to redirect users based on role and content of redirect_to?
- Moving code from theme header to functions.php
- Showing latest post without 301 redirect
- Having Issue on Redirecting With Session in WordPress
- Returning data instead of echoing/printing
- Using a $GET parameter from a URL, to redirect to a URL (WordPress)
- WordPress redirect redirecting too many times or not at all
- I am receiving a pluggable.php warning sign on my only http:// page
- Login redirect. Check user meta and redirect accordingly
- Where to insert redirect code based on http_referer?
- Is this a correct usage of ob_start() in my WordPress project?
- How to allow download url redirection only if user logged in WordPress site?
- PHP Redirect condition
- Find out last 7 days of upload images, last week uploaded image from Gallery and display them in different pages
- How to get the filename from file system and create a download link?
- how to get attached file url for current post?
- Manually Create PHP Page For A Redirect
- Front end file upload returning wrong attachment url
- Attaching images to posts manually (i.e. with custom code, without the use of an API)
- Redirect to current user page upon link click
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- How to load previous or next attachment with jquery ?
- Writing a link cloaking plugin
- WordPress permalink issue
- WP insert post Redirect after function has executed
- How to redirect non logged in mobile users to page on same site?
- Add class to all img if they have a certain ACF field
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Download file and redirect to page or vice versa
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- 404 on old link after changing post url
- WordPress url By country code?
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- Unable to delete related media attachments with deleted post
- Implementing a multilingual WordPress site by installing several instances of WordPress and redirecting
- WordPress on Ubuntu – “File not Found” for home.php – Trying to Redirect to Root Folder
- Remove all feeds and return custom 404 page
- Attach and retrive multiple pdf files to post or page
- Redirect User when they click Menu Option
- WordPress: Redirect Main Site to Subsite in Multisite Where user is NOT logged in
- Get list of posts from attachment
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- wp-login.php?redirect_to=https problem
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- WordPress Redirect / Add_Rewrite_Rule – Non Index.php Page
- Override 404 when navigating to single php file
- Submit to itself don’t work
- redirect 301 with special character like WIX site “#!”
- 301 redirect from webpage to wordpress page in the same root
- Get posts associated with media attachment
- Submitting my form to the database and then redirecting to payment site
- File path for attachments outside of wp-content/uploads
- Attachments doesn’t update
- Target all images that are not the first attachment
- 3 domains, 1 wordpress install, redirecting and changing domains on live site
- Get permalink for a post from inside WordPress and route to a related site
- Redirect users not logged in to the standard login page (and back) from some posts and pages
- Correct Syntax for uploading files to custom directory in WordPress
- Link to external page has wordpress blog-url inside
- How to create a WordPress PAGE in another folder?
- index.php file keeps redirecting to a non-existent index.html file?
- Redirect loop upon installation of my plugin
- wp_login_url always redirects me to wp-admin
- wp-login – unable to redirect user to a custom login url
- Redirect to current URL and append specified URL parameter on unsuccessful login through Elementor login form widget
- Redirect WordPress page to the latest created post by the logged in author/user