I believe I’ve found the solution. I add the following
RewriteRule ^example_directory/files/(.*) new_directory/$1
to my WordPress .htaccess rules like so:
RewriteEngine On
RewriteBase /
RewriteRule ^example_directory/files/(.*) new_directory/$1
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
I couldn’t get it working before and I think the key was moving the new RewriteRule
directive to the line directly following RewriteBase /
Related Posts:
- custom htaccess rewrite rule for page
- Why is there /index.php/ in all my links? How do I remove it?
- subdirectory install breaking existing links
- Preserve old website URL structure after migrating to WordPress
- WordPress is adding “category” word before my actual category name in url (and this is unsolicited)
- Migration from old CMS to WordPress 301 redirection rules?
- Change the “page” slug in pagination
- Change author base slug for different roles
- Masking wp-content/themes/name/images to just images directory using htaccess
- Using custom/dynamic “slug” for a page
- Passing parameters to a custom page template using clean urls
- How to add custom rewrite rule to .htaccess?
- Use subdomain for certain urls
- Display posts with author in the url with custom post types
- Clash of the rewrites
- How to seamlessly redirect between different archive and singular slugs?
- How to add dot(“.”) in post slug
- How to change default page slug?
- Handle category name URL rewrite before different post type slugs
- How to remove “admin.php?page=” from wp-admin using .htaccess?
- Changing directory and/or URL structure
- SEO Friendly URLs for my plugin categories
- How do I remove a word from a url in WordPress using .htaccess?
- Hijacking the URL for filtering
- Rewrite rules in .htaccess get overwritten?
- Custom rewrite rules are sending everything to index.php
- How to change ?lang=cn into /cn/
- WordPress keeps writing rewrite rules to .htaccess
- WordPress Rewrite
- Dynamic URL, not a physical page within the database
- unexpected problem in url rewrite
- Redirecting all old links from previous EE site to new WP site in one go?
- Prevent WordPress from automatically correcting URLs
- Two “.htaccess” Files Located in Different Directories?
- Server (WordPress) redirects files that are not supposed to (using htaccess)
- WordPress redirection to get url friendly
- Rewrite WordPress Custom URL
- htaccess: Remove trailing slash from URL ending with .xml/ only
- Multiple Permalinks for Same Post
- External/non-WP rewrite rule without QSA
- Issue with using .htaccess to redirect feedburner feed
- Adding more pages to author pages
- Using Blog Parent Slug on Blog Posts Only
- Remove all categories from URL
- Custom rewrite rule
- Remove special characters in a URL
- Add query string to url and display it as normal url part /folder/
- Load a template page based on part of slug in wordpress
- Alias ‘wp-content’ directory to something shorter (framework?)
- WordPress .htaccess – route other URLs to another app
- Removing “category” from URLs then “add_endpoint()” won’t work…
- hard flush_rewrite_rules() not regenerating .htaccess
- Map alt domain to specific section of website w/o MU
- Remap URLs from Relative to Absolute
- Rewrite rule to load images from production does nothing
- Cleanup URL for a custom page in wordpress
- WordPress rewrite rules don’t need ^?
- WordPress SSL (https) is not working with custom permalink
- How do I change attachment slug from name to id
- Changing RSS feed URL structure
- Can’t Access Subdirectory
- How to redirect http://mydomain/blog/blahblah/ to http://mydomain/blahblah/ in wordpress htaccess?
- add_rewrite_rule fro html to another url not working
- Adding rewrite rules directly to .htaccess file
- Double domain name in category URL-s
- NextGEN Gallery Lightbox – Social Share URL Redirect
- Url Rewriting a dynamic wordpress page
- WordPress .htaccess blocks mine?
- Preserve Domain Alias
- My WP_options db rewrite_rules Does Not Work
- Disable Pagination on Pages
- Rewrite Preview URL to include index.php
- WordPress Redirecting Non Category Pages /page/nnn to their Canonical URLs
- Adding special characters to slug?
- a one-off rewrite rule
- .htaccess rewrite
- How can I dynamically generate an image with a static image URL?
- Change htaccess to redirect to index.php in subfolder
- How to remove wordpress directory slash
- Cannot access wp-admin without trailing slash – .htaccess configuration for WordPress behind a nginx proxy
- Changed pagination URLS to use p= instead of paged=
- Wildcard forward all posts and pages with few exceptions
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- “View post” leads to odd URL
- React Router with WordPress
- joomla to wordpress migration and 404 errors issues [closed]
- Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page
- Replace specific middle part of url
- subdirectory index.php is not working
- Map secondary domain to other’s virtual subfolder
- Rewriting a subdomain page on one WordPress installation to a parent domain on another
- Redirecting /px/?q=x to /px/x/
- How to change the Author Slug from Username to Nickname and deal with Special Characters
- URL redirect on updating the post date
- WordPress keeps writing rewrite rules to .htaccess
- Customise particular RSS permalink
- htaccess rewrite, adding segment to url
- RSS feed rewrite matching wrong rule
- Redirect to another page using contact form 7? [closed]
- Rewrite vs Redirect from ?p={ID}