permalinks - Link works although page was moved to another location

admin2025-06-06  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!

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!

Share Improve this question asked Nov 1, 2018 at 15:36 PinckcloudPinckcloud 31 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749213243a317311.html

最新回复(0)