Description
Preconditions and environment
- version 2.4.7-p4
- normal deployment which uses /pub/ directory for all the static content with latest .htaccess in both the root dir and /pub/ dir
Steps to reproduce
To reproduce:
- Navigate to admin
- Marketing -> SEO & Search -> URL Rewrites
Add URL Rewrite with:
- Custom a Request Path value that begins with three letters: pub (e.g. public-facing-url-that-breaks-sad-cry, publishing-is-so-wonderful.html)
- Target Path that points at a product detail page
- Redirect Type: No
Expected result
https://exampleurl.com/public-facing-url-that-breaks-sad-cry loads the product defined by Target Path
Actual result
https://exampleurl.com/public-facing-url-that-breaks-sad-cry does not the product defined by Target Path and fails with a 404 error page
Additional information
knowing how there are both apache .htaccess rewrites plus magento rewrites, it can get a bit messy to figure out where the issue is happening. we were able to trace the problem back to some very old laminas code in: vendor/laminas/laminas-http/src/PhpEnvironment/Request.php
This is the fix we implemented to get things working as one possible option though it does mean we will now have to re-apply the patch after each deployment to ensure it doesn't revert, so perhaps there is a better way you all can come up with to solve for this issue.
// Directory portion of base path matches.
$baseDir = str_replace('\\', '/', dirname($baseUrl));
- if (0 === strpos($requestUri, $baseDir)) {
- return $baseDir;
+ if (0 === strpos($requestUri, $baseDir)) {
+ // BEGIN CUSTOM
+ // Skip only if baseDir is exactly "pub" or "/pub"
+ if (!in_array($baseDir, ['pub', '/pub'], true)) {
+ return $baseDir;
+ }
+ // END CUSTOM
}
Maybe there's a more robust or alternative option to fix this more elegantly. Thanks!
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.