WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7306 closed defect (bug) (fixed)

Error 404 with /index.php/%postname%/ permalink strucutre

Reported by: aarnet Owned by: markjaquith
Milestone: 2.6.1 Priority: normal
Severity: normal Version: 2.6
Component: General Keywords:
Focuses: Cc:

Description

404 error appears on all permalinks when blog uses following permalink structure: /index.php/%postname%/.

Front page with posts shows OK. Clicking any post headings will give 404 error. Also archives (myblog.com/index.php/2008/07/) will give 404 error.

Pages (myblog.com/index.php/page title/) are working OK.

Tried with different themes and they all produce same error. Changing permalink scheme to default will solve problem but that's not an option normally.

My opinion is that bug appeared in V2.6 beta 3.

Change History (19)

comment:1 DD326 years ago

Appears to be caused by a conflict with the Tag base when using Pathinfo permalinks.

This is the Tag rewrite rule:

'index.php/(.+?)/?$' => string 'index.php?tag=$matches[1]'

Which prevents Postnames from being matched.

One solution is to add category and tag basenames.

comment:2 Otto426 years ago

Here's where it got broken, in rewrite.php: [8213]

If those two options are blank, then that was supposed to me that the default values are supposed to be used. In that case, the tag_base and category_base would also be blank, and this code down in get_tag_permastruct handled the default value case:

if (empty($this->tag_base))
    $this->tag_structure = $this->front . 'tag/';
else
    $this->tag_structure = $this->tag_base . '/';

By forcing the index.php into the tag and category bases, those values will never be blank if you use index.php in your permalink structure. Thus breaking permalinks for the default case of blank category/tag bases.

Adding a simple "category" and "tag" to those bases fixes it as a temporary solution, but ideally this code needs to be altered to use the default values as well, instead of just whatever get_option returns, which can be blank.

comment:3 Otto426 years ago

  • Milestone changed from 2.7 to 2.6.1
  • Priority changed from normal to high
  • Severity changed from normal to critical
  • Version set to 2.6

comment:4 ryan6 years ago

  • Owner changed from anonymous to markjaquith

comment:5 santosj6 years ago

Shouldn't this be fixed in trunk first?

comment:6 markjaquith6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [8365]) Better solution for #4536. Slashless normalization of tag/category bases. fixes #7306 for trunk. see #4536

comment:7 markjaquith6 years ago

(In [8366]) Better solution for #4536. Slashless normalization of tag/category bases. fixes #7306 for 2.6.1. see #4536

comment:8 in reply to: ↑ description randomperson836 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Replying to aarnet:

404 error appears on all permalinks when blog uses following permalink structure: /index.php/%postname%/.

Front page with posts shows OK. Clicking any post headings will give 404 error. Also archives (myblog.com/index.php/2008/07/) will give 404 error.

Pages (myblog.com/index.php/page title/) are working OK.

Tried with different themes and they all produce same error. Changing permalink scheme to default will solve problem but that's not an option normally.

My opinion is that bug appeared in V2.6 beta 3.

comment:9 randomperson836 years ago

I replaced my /wp-includes/rewrite.php file, that did not fix the error. Links such as myblog.com/blog/index.php/anything_here are not working.

comment:10 randomperson836 years ago

For a demonstration of the error, see my blog: http://www.virtualroadside.com/blog/ ... I'm at work now, so I can't debug it. I'll try looking at it tonight (6pm EST), thanks if you can figure it out before then.

comment:11 ryan6 years ago

Did you force an upgrade. If you didn't replace the version.php, the upgrade that fixes your rewrite rules won't happen. You can either replace version.php with the new one or click "Save Changes" in your Settings->Permalinks page.

comment:12 randomperson836 years ago

Ah... that did fix it. Didn't realize thats how it worked. Thanks for the quick response! :)

comment:13 ryan6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

comment:14 ryan6 years ago

Thanks for the confirmation.

comment:15 Nunnsby6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Upgraded, had the 404 problem, applied the 3 files that are mentioned in 8366 (will update this post there too). Restarted Apache2. Weirdly it asked me to update/upgrade my database. I then went to the settings page, and selected save for the permalinks. Imagine this is the correct procedure, now it just gives me:

Not Found

The requested URL /2008/07/02/getting-out-to-the-ghettos-luanda/ was not found on this server.

It still works when I set to default, as in: http://www.nunnsby.com/?p=123

Have reopened, but just realised this now doesn't really apply to the 404 error anymore, but still an error.

Any ideas?

comment:16 Nunnsby6 years ago

Oh, just thought I would add to the above comment -

Category Base and Tag Base are both blank.

comment:17 follow-up: Otto426 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Nunnsby: If you're not using "index.php" in your permalink settings, then this doesn't apply to you. Your error sounds like a straightforward .htaccess problem to me. Try the support forums.

comment:18 in reply to: ↑ 17 Nunnsby6 years ago

Replying to Otto42:

Hey Otto42, thanks, okay I was using index.php, and forgot to put it in, so fixed now.

How do I move away from having index.php in my permalinks? I am not using a .htacess file.

comment:19 Otto426 years ago

  • Priority changed from high to normal
  • Severity changed from critical to normal

Nunnsby: This question is more suited for the support forums, so let's take it over there.

However, the basic answer to your question is that you must use an .htaccess file to avoid requiring index.php in the permalink string.

Note: See TracTickets for help on using tickets.