WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#11192 closed defect (bug) (worksforme)

WP_Rewrite causes 404 errors

Reported by: PrograMedia Owned by: ryan
Milestone: Priority: normal
Severity: normal Version: 2.8.5
Component: Rewrite Rules Keywords: 404 rewrite
Focuses: Cc:

Description

the quick and dirty example at http://codex.wordpress.org/Function_Reference/WP_Rewrite caused 404 errors with my custom redirects. After a lot debugging I found in classes the function handle_404().
There is a check when there are no posts it generates always 404:

if ( (0 == count($wp_query->posts)) && !is_404() && ...

As I had no posts I always had 404 in my pages. Just adding a dummy post solved my problem.

My suggestion is to check if there are no posts, to check also if there are custom rules before generating 404.

Change History (2)

comment:1 ryan4 years ago

  • Type changed from task (blessed) to defect (bug)

comment:2 nacin4 years ago

  • Milestone Unassigned deleted
  • Resolution set to worksforme
  • Status changed from new to closed

You can override the 404 that gets sent. Closing as worksforme; re-open with reporter feedback, or try the support forums.

Note: See TracTickets for help on using tickets.