Answering this here to save others time if they run into a similar issue.
Clarity on this issue provided in this answer on SO
Regular expression redirects only work when all the information about
the new location can be derived from the URL for the old location.
That isn’t the case here. You have new information in the new URLs.
The data that the document was uploaded is now in the URL when it
wasn’t before. There is no way to write a single rule with a regular
expression to redirect all the URLs.You have a couple options:
- Redirect each PDF URL individually
- Upload your PDFs to your new site in their original locations
For my situation option #1 works best as follows (sample redirect using redirection plugin):
Source URL: /folder/sub-folder/sub-folder/somepdf.pdf
Target URL: /wp-content/uploads/2022/07/somepdf.pdf
Create a csv of the redirects and bulk upload.
Related Posts:
- How to remove “YEAR/MONTH/” from uploads URL & redirect old URL to the new form?
- htaccess redirect – replace special character
- Regex with HttAccess
- Regex redirect rule for missing part of the path
- Redirect 301 of old urls to wordpress urls
- Redirect after Permalink change – What regex do I use?
- PHP header(Location: …): Force URL change in address bar
- WordPress localhost site redirect to live site
- WordPress Redirect All HTTP requests to HTTPS via .htaccess
- wp_redirect() function is not working
- My wordpress multisite homepage redirects to signup page
- Login redirect to previous page
- Prevent access to single post types
- WordPress install enters an infinite loop
- WordPress HTTPS redirect loop
- 301 redirect not working through .htaccess
- handling login/logout redirects
- Using `auth_redirect` : keeps asking me to login even when I’m logged in
- How can I move/redirect single blog posts from one blog to another?
- 302 redirect instead of 301 after switch to HTTPS
- How do I skip wordpress’s 404 handling?
- Redirecting to home-page when saving any edited code
- Temporary redirect prevents getting $_POST array
- Can WordPress redirect to a “similar page” in case of 404 error
- Hacked website redirect, only on desktop, help with restoring it [closed]
- Can I check for maintenance mode before redirecting to subdomain?
- How to create a 301 redirect that doesn’t apply to subsites
- WordPress blocking/preventing viewing of .cgi file in subdirectory [closed]
- Custom Registration page – prevent redirect to wp-login.php?action=register
- How to target specific user role?
- How to auto login after registration? [duplicate]
- homepage redirects to login page when user session expires
- How to redirect user to a specific page based on username?
- Redirect blog archive into certain format
- How to publish new posts/pages in root instead of subfolder, but keep old structure in place?
- Contact Form 7 Data to Whatsapp Link
- htaccess 301 Redirect not working for WordPress site
- Auto-detect the redirect url from the original url
- How can I replace my primary url globally with a parked one?
- WordPress Auto-Redirecting on 404
- I need to redirect an entire subdirectory in WordPress to the homepage – is this correct?
- My website on checking showing 403 error on HTTP Status [closed]
- I get redirected too many times only in wp-admin?
- Redirecting Pages That No Longer Exist — But Could in the Future
- How do I determine what is causing a redirect for a given page?
- Trouble running local WordPress in Google App Engine
- Empty folder being created by WordPress, breaks site
- About to migrate site to new domain
- Redirect all users to dashboard unless custom post type
- Redirecting connection from IP to localhost
- WordPress directing to Posts page (edit.php) instead of saving post
- HTML Redirect to WP pages
- How to redirect 40,000 urls with the same url structure efficiently?
- Changing theme = change home page for mobile visitors?
- Redirect User on Login based on role WP 3 – Multi-Site
- production site routes to staging site after cloning
- Custom URL routes
- Duplicated WP site manually, now links redirect wrong [closed]
- redirecting an entire WP site from one top level domain to another
- Load function with login_redirect
- Missing domain http://./wp-… in redirects
- All URLs Redirect to Main Page
- 301 redirects in Headway based WordPress Site
- Why I am not able to direct user to my blog section without login?
- Force User Login
- Import RSS as posts with redirect?
- Parked domain redirecting to wrong error404 page
- redirect from old URL structure
- How to Redirect WordPress domain.com/?anyword to 404 Page?
- How can I prevent caching of wp_redirect?
- Is the default value of FORCE_SSL_ADMIN documented?
- Redirect Category Media ‘URL’ when clicked
- Error in /blog redirection – ubuntu default WP installation
- wordpress automatic URL ‘page’ parameter rewrite
- Changing post depending upon where you’re redirected from?
- 302 redirect *.at/site redirecting to .comsite
- Loading /wp-content/uploads/site as /site/
- How to redirect user to the specific URL and display notice
- when contact form7 submited domain redirects to example.com means (example domain)
- How to manage around 90k 301 redirects after migration from old CMS
- Local domain remap with proxy : Infinite 301 redirect, bad URL typo
- How to 301 redirect to subdirectory but keep access to wp-admin of main domain
- Pagination redirect set in .htaccess file is not working
- Count users redirected from Facebook
- Redirecting a POST to a php script
- automaticly redirect link problem on update
- WordPress Login Page redirecting after failed login
- Redirect after empty register form
- Displays url’s twice and getting 404 errors after activating
- Redirect once on first visit
- How to permanent redirect old domain to new one. in case amazon store
- Bookmark anchor link to load another page first before completing?
- How to map secure.domain.com to www.domain.com or domain.com with “WordPress MU Domain Mapping” on the primary multisite domain?
- Simple Redirect but getting the right code?
- 301 redirect just for 404 to another domain
- How to redirect users without permission to view content to a custom page?
- redirect the root of a domain, while leaving the www version unredirected
- How to Create Custom Route to a page in WordPress
- How to create a redirect to another domain like safe redirect manager from php
- Post Migration Site Migration Redirects All Known Solutions Attempted