0

Sorry if this is a duplicate but I didn't find my answer in "Questions that already have your answer".

Currently on my site if I visit an old URL link or if I outright make up a URL like example.com/made-up-place.html I am getting redirected with a 302.

Whats weird is that it 302's by default instead of 301 for moved URLs, but I'm really intrigued as to why a URL that has never existed 302's back to the homepage. So my two questions are:

  1. How do I force all 302 to 301 (I would think there is a hook to add into functions.php)?

  2. Why would made up urls to a file 302 and not 404?

I would like some understanding of what I'm seeing.

Edit 1:

My theme does have a 404 template that does work in some situations. Example:

Current site URL structure is: example.com/id/1234/slug

  1. If I put in an invalid URL like example.com/id/999999 then i would get a 404 response which is expected.
  2. If example.com/id/999999/some-slug I see a 301 on some-slug followed by a 404 on the full URL.
  3. example.com/some-made-up-thing.html this goes to 302 instead of a 404. Past site structure was example.com/slug (but no pages ever included the extension) and this page had never existed.

What is interesting is that this only occurs on the main domain. All subsites (example2.com, example3.com) all work correctly and as expected #1, #2, and #3 all 404 as they should!

0

This is the default because of a number of reasons. The first would be that you could still have a plan for your old URLs, or they are just temporarily not available, so WordPress defaults to this.

If the default would be an 301, it could easily be that your previous URLs are indexed by search engines as "does not exist in this place anymore, I won't have to look again", so you lose your pagevalue.

However, if your template has a 404.php, WordPress sends a 404 page as a result.

Please note that WordPress still uses 302 redirects, if your posts and pages get a new URL Structure within WordPress (not switching from a different system).

I hope this helps :)

  • I will update my question with the full scope of what I am getting. I understand some of what you are saying as far as previous URLS but I am seeing conflicting results. Thanks for the answer as well. – Shawn Jan 24 '14 at 17:29
  • I updated the question details. – Shawn Jan 24 '14 at 17:39
0

This issue was being caused by an edit in the wp-config around NOBLOGREDIRECT. The main domain was not being handled correctly.

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.