1

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.

BACKGROUND:

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):

our-services
- 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:

our-services
- technical-writing
- - graphic-design
- - project-support

What has me confused is this:

If you point your browser to this...

http://example.com/our-services/graphic-design/

or this...

http://example.com/our-services/project-support/

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

http://example.com/our-services/technical-writing/graphic-design/

and this...

http://example.com/our-services/technical-writing/project-support/

respectively.

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...

http://example.com/graphic-design/

or ...

http://example.com/project-support/

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]
1

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.