I redesigned an old (static) website to WordPress CMS. Now that site is WordPress based with 'blog' as a page displaying all posts. On previous (static) version, they already had a separate WP blog inside /blog directory. I imported all old blog posts to our new WP setup but problem is with images. On old blog, images inside posts had source like http://www.example.com/blog/wp-content/uploads/../x.jpg
But once all posts were imported to new site, these image paths didn't change in imported posts and now are all broken links.
I tried fixing this issue by creating an empty folder blog
on root, with only wp-content/uploads
folder in it so paths to old images keep working. But now my new blog page is not working. Instead of showing /blog
posts, it shows contents of blog
directory. This is because of .htaccess which knows that /blog
is an existing directory which exists and doesn't pass request to index.php.
Now the only solution is to tell .htaccess to consider only those '/blog' directory requests which are image URLs and the file exists. And pass rest of requests to index.php.
Default .htaccess content looks like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
How do I achieve this?
Thanks.