Redirect url to a page after importing posts

After importing posts from one WordPress site to another, you need to set the htaccess file to direct the pages and images. Here’s what I used:

The old site where I exported posts is I created a new page that will be a section page for these posts at So I need to redirect the old homepage, the old stories and the images. I added these three rules to the htaccess file on

# redirect old homepage to new page
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{REQUEST_URI} ^\/$
RewriteRule ^(.*)$ [L,R=301]

# redirect files from old site /files/ to new site /wp-content/uploads/
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*/)?files/(.*)$$2 [R=301,L]

# redirect every other page to match the post’s permalink on new site
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

These are the example redirects:
redirect the homepage to a page

redirect an image×128.jpg

redirect a story

Leave a Reply