Make WordPress Core

Opened 9 years ago

Closed 5 years ago

#19688 closed defect (bug) (wontfix)

Using pathinfo permalinks in a subdirectory causes some 404's

Reported by: mose9634 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3
Component: Permalinks Keywords: needs-patch reporter-feedback
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Due to circumstances beyond my control, I have a Wordpress site that must be installed to a subfolder named "s". I also must use pathinfo type permalinks - thus a page with a slug of store-locator would have the url /s/index.php/store-locator. Unfortunately this results in a 404, but other pages on the site work properly.

I tracked this down, and what I found is that code in class_wp->parse_request is causing this - particularly the code starting around line 166ish in version 3.3. The lines in particular that mess things up are these three:

$pathinfo = trim($pathinfo, '/');
$pathinfo = preg_replace("|^$home_path|", '', $pathinfo);
$pathinfo = trim($pathinfo, '/');

Coming into these lines of code, $pathinfo is /store-locator/, but after those three lines of code $pathinfo is tore-locator (the leading s is missing). This is because $home_path comes from home_url() which strips trailing slashes. The code right before this block further strips $home_path down to just the subdirectory portion, which in my case is just "s". Then the preg_replace fires and the leading s on the path is lost.

Temporarily, I added the following line before the three lines above and my problems went away:

$home_path .= "/";

Obviously this only works in my particular situation, and I'd like to be able to run vanilla Wordpress, but I can't find any combination of settings that will preserve my required permalink structure and still work. If there's a configuration combination that I'm missing, I'd be very happy, otherwise, feel free to contact me if you would like more info or if I can help in any way.

Change History (6)

#1 follow-up: @mikeschinkel
9 years ago

  • Cc mikeschinkel@… added

What is /store-locator/, a $post_type=='page', or something else? I'm wondering if this wasn't instead added by a plugin?

#2 in reply to: ↑ 1 @mose9634
9 years ago

Replying to mikeschinkel:

What is /store-locator/, a $post_type=='page', or something else? I'm wondering if this wasn't instead added by a plugin?

No plugins involved here - this is just a normal page. In fact, if I take a "working" page and update the permalink to start with the letter s, that page begins to 404 as well.

Some more information:
Permalinks are set to custom with a format of /index.php/%year%/%monthnum%/%postname%/ and .htaccess is empty. Both the Wordpress Address and the Site address are set to http://domain.com/s (I can't hand out the real URL due to contractual obligations, unfortunately). Note that I've tried saving the Wordpress and Site addresses with a trailing slash, but those are stripped out when things are saved.

#3 @SergeyBiryukov
9 years ago

  • Description modified (diff)

#4 @chriscct7
6 years ago

  • Keywords needs-patch reporter-feedback added

@mose9634 can you still reproduce this on 4.0?

#5 @Mose9634
6 years ago

Unfortunately, I don't have access to the site any longer. If need be I could try to get a test version set up locally, though it might be a while before my schedule clears to that point. Sorry I don't have an easier/quicker way to verify :(

#6 @afercia
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This ticket is 4 years old and seems to describe an extremely edge case. No activity in the last 13 months, closing out. Please feel free to re-open if you think it's a relevant issue for the majority of users.

Note: See TracTickets for help on using tickets.