$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>permalinks - Link works although page was moved to another location|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

permalinks - Link works although page was moved to another location

matteradmin9PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far