I hope someone can explain how WordPress knows to properly serve up a page that has been moved - even when using the "pre-move" URI. I would expect to get a "404". Instead, WordPress redirects to the page using the new URI.


The original structure of the "Our Services" branch of the Web site in question looked like this (using post_name values and leading hyphens to indicate lineage):

- technical-writing
- graphic-design
- project-support

The client decided to make graphic-design and project-support children of technical writing. The resulting structure looks like this:

- technical-writing
- - graphic-design
- - project-support

What has me confused is this:

If you point your browser to this...


or this...


.. then the browser will redirect to this...


and this...



I'm not complaining, mind you. But I don't understand how this is working and I want to.

Note: Trying to access those pages from the root...


or ...


does result in the expected '404/not found'.

The .htaccess file has the default WordPress directives and this above them:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule ^ http://example.com%{REQUEST_URI} [L,R=301]

WordPress uses the redirect_guess_404_permalink() function as part of its canonical api to produce these results:

Will also attempt to find the correct link when a user enters a URL that does not exist based on exact WordPress query. Will instead try to parse the URL or query in an attempt to figure the correct page to go to.

You can disable this functionality via a filter or by using a suitable plugin, or it can be over-ridden via the .htaccess file.

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.