Skip to content

Fix case-insensitive handling of .php extensions - #2046

Open
sy-records wants to merge 1 commit into
php:masterfrom
lufei:fix/error
Open

sy-records wants to merge 1 commit into
php:masterfrom
lufei:fix/error

Conversation

@sy-records

Copy link
Copy Markdown
Member

Close #2045

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

📊 Regression report for commit d909a48 is at https://web-php-regression-report-pr-2046.preview.thephp.foundation

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Preview for commit d909a48 is available at https://web-php-pr-2046.preview.thephp.foundation

@sy-records
sy-records marked this pull request as draft October 28, 2026 03:30
@sy-records
sy-records marked this pull request as ready for review October 28, 2026 03:37
Comment thread public/error.php Outdated

// Fix for case-insensitive .php extension, e.g. /supported-versions.PHP, /downloads.PHP
$originalURI = $URI;
$URI = preg_replace('/\.php\z/i', '.php', $URI);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use \z over $ here? (I had not seen \z before, so had to look it up!)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using $ is enough here; I've modified it.

Comment thread public/error.php
if (!in_array($phpPageName, ['mirror-info', 'error', 'mod'], true) &&
file_exists(ProjectGlobals::getPublicRoot() . "/$phpPage") &&
(!$hasPhpExtension || $URI !== $originalURI)) {
mirror_redirect("/$phpPage");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What situation does this address? The commit message only talks about the case-insensitivity.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This redirects the incorrect address to the correct one. e.g. php.net/downloads.PHP to php.net/downloads.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Top "PHP download" Google search result leads to 404 page

2 participants