0

I am a new to WordPress. Please help me with the following issue.

I created page A and set Parent to X, hence its permalink was displayed as "http://websitename/index.php/X/A/".

In page B, I reference to page A by the attaching the link "http://websitename/index.php/X/A/" there

I then changed Parent of page A from X to Y. The permalink of A thus was updated as: "http://websitename/index.php/Y/A/"

I visit page B again and click on link "http://websitename/index.php/X/A/", it still works and brings me to link "http://websitename/index.php/Y/A/"

I wonder how it could happen? I was expecting to see Page Not Found or something like that as link "http://websitename/index.php/X/A/" is no longer available.

There probably is something I don't know about how the link in WordPress works. Can somebody please help explain this to me? Thanks!

0

That is called canonical redirect.

And it's done through redirect_canonical() which basically

Redirects incoming links to the proper URL based on the site url.

and

Will also attempt to find the correct link when a user enters a URL that does not exist based on exact WordPress query.

(Those excerpts were both taken from the function's reference.)

So in your case, although the post parent of A has changed from X to Y, the post A (or a post with that slug) still exists, and therefore, when you visit the old URL:

http://websitename/index.php/X/A/ (old URL - post parent is X)

with canonical redirect, you'd be redirected to the correct URL:

http://websitename/index.php/Y/A/ (new URL - post parent is Y)

and not being presented with a 404 (page not found) error page.

Try visiting http://websitename/index.php/A/ and you'd see the canonical redirect being applied.

And if you visit http://websitename/index.php/A123z/, assuming there are no post with A123z as the slug, then you'd see the 404 error page.

  • Thanks for your information, Sally! Does that mean I just can leave it the way it is and the moved pages will be automatically found without having to direct them to the new URLs? As I was worry that the pages just accidentally show because of caching. – Pinckcloud Nov 1 '18 at 19:57
  • Yes, you can leave that behavior, which is default in WordPress. It's unlikely caching issue, but you can disable all plugins to confirm that. This post has a more in-depth explanation regarding canonical redirects in WordPress - the info are mostly still valid despite the post date. Alternatively, just Google for "canonical redirect wordpress" without the quotes.. :) – Sally CJ Nov 1 '18 at 20:15
  • You're welcome, I'm glad I could help you. =) – Sally CJ Nov 1 '18 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.