Redirecting twice result in loop error message

I have several product images that I’m no longer using after I updated and restructered the product catalogue. I would delete them, except for the fact that their attachment pages in WordPress have been indexed by Google, so if I did that I reckon the visitor would se a 404 error.

I would automatically redirect from the attachment page to the parent post by changing my theme’s image.php to just this: <?php wp_redirect(get_permalink($post->post_parent)); ?>, but that gives me the error message:

Read More

This webpage has a redirect loop

ERR_TOO_MANY_REDIRECTS

I suppose this is happening beacuse the parent post is aready ridirecting to a new and updated page I made to replace the old one.

So is it not allowed to redirect twice? Why is it saying that there’a a loop? It shold redirect from image attachment page to parent post to new page, can’t see any loop there. How could I fix this?

Related posts

1 comment

  1. Nevermind, missed the obvious solution, this plugin that I already had installed does the trick nicely. I just redirect directly from each unused image’s attachment page to the relevant new page.

Comments are closed.