Skip to content

Get correct URL for all cases - #141

Closed
schorschii wants to merge 1 commit into
matomo-org:masterfrom
schorschii:track-url-improvement
Closed

Get correct URL for all cases#141
schorschii wants to merge 1 commit into
matomo-org:masterfrom
schorschii:track-url-improvement

Conversation

@schorschii

Copy link
Copy Markdown

Description

I noticed that the URL is not correctly found out in all cases.

Example URL: https://example.com/dir1/test

In this example, "dir1" is a real existing directory on the server, and "test" is a additional string appended and handled by the index.php script in this dir (via Apache rewrite). In this case, the MatomoTracker will track "/test" instead of "/dir1/test". This change fixes the behavior to correctly track "/dir1/test".

Checklist

  • [NA] I have understood, reviewed, and tested all AI outputs before use
  • [NA] All AI instructions respect security, IP, and privacy rules

Review

@sgiehl

sgiehl commented Jul 27, 2026

Copy link
Copy Markdown
Member

Thanks for reporting and for the patch, @schorschii!

We picked this up in #154. The root cause is exactly what you found — PATH_INFO only contains the trailing path-info segment, so it truncated the URL. Since REQUEST_URI already carries the full requested path (and PATH_INFO is always just a suffix of it), #154 drops PATH_INFO entirely rather than only reprioritizing it, adds regression tests, and updates the changelog.

Closing in favor of #154 — full credit to you for the report.

@sgiehl sgiehl closed this Jul 27, 2026
sgiehl added a commit that referenced this pull request Jul 27, 2026
* Detect the tracked page URL from REQUEST_URI, not PATH_INFO (#141)

getCurrentScriptName() builds the auto-detected page URL (the path
between host and query string). It preferred $_SERVER['PATH_INFO'],
which only holds the trailing path-info segment — so with front-
controller / path-info routing (e.g. /dir1/page handled by
dir1/index.php) the tracker recorded a truncated '/page' instead of
'/dir1/page'.

REQUEST_URI already contains the full requested path (PATH_INFO is
always just a suffix of it), so use it as the source and drop PATH_INFO
entirely; SCRIPT_NAME stays as the fallback when REQUEST_URI is absent.
This also aligns the primary source with Matomo core's Url helper.

Reported in #141.

* Drop the ticket number from an inline test comment

Keep issue references in the CHANGELOG and git history, not in code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants