I have a bunch of posts that contain images with urls that follow this pattern:
.png
I've imported the posts into a new install of wordpress on the same domain with file structure where the files now reside at
.png
Because "example_directory" is now a category slug, I cannot simply update the new directory structure to mirror the old one.
How can I make the files inside new_directory
appear when my browser tries to visit urls at directory/files
?
I have a bunch of posts that contain images with urls that follow this pattern:
https://example/example_directory/files/2019/04/file.png
I've imported the posts into a new install of wordpress on the same domain with file structure where the files now reside at
https://example/new_directory/2019/04/file.png
Because "example_directory" is now a category slug, I cannot simply update the new directory structure to mirror the old one.
How can I make the files inside new_directory
appear when my browser tries to visit urls at directory/files
?
1 Answer
Reset to default 1I 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 /