# Public SEO and URL normalization

## Canonical addresses

The production canonical host is `https://rollschool.pl`. `Seo` owns public
metadata and canonical paths. Public page paths end in `/`; the homepage is `/`.
`Sitemap` uses the same host and slash convention for static pages and active
instructors, locations, class categories, groups and courses. Account pages,
administration and state-changing actions are excluded from the sitemap.

`public_html/.htaccess` permanently redirects the historical production hosts
`www.rollschool.pl` and `zapisy.rollschool.pl`, retaining paths and queries. It
also redirects historical public page aliases and enforces HTTPS on production
and `test-next.rollschool.pl`. Local HTTP remains supported.

`ENVIRONMENT = 'DEV'` blocks indexing through metadata and the `X-Robots-Tag`
header and uses the configured `URL` for development metadata. No environment
configuration changes are required for trailing-slash normalization.

## Trailing-slash redirects

Before controller dispatch, `public_html/index.php` asks
`Seo::trailingSlashRedirectPath()` whether the original request URI needs a
permanent HTTP 301 redirect. A missing final slash is added and repeated final
slashes are collapsed to one only for GET and HEAD requests to known public
read routes:

- Static paths declared in `Seo::getRoutePages()`.
- Numeric `pokaz/{identifier}` pages for instructors, locations, class
  categories, groups and courses.
- Audience filters, location filters, calendar season filters with up to six
  numeric parameters, and the public RollPoints information page.

The Location header is root-relative, keeping the current environment's host.
The original query string and path filters are preserved. Already normalized
paths never redirect again. POST and other methods, account and administration
actions, payment callbacks, signup actions, files, crawler resources, unknown
routes and unsafe URIs are not normalized by this mechanism.

For example, `/instruktorzy/pokaz/35?utm_source=test` redirects to
`/instruktorzy/pokaz/35/?utm_source=test`. Existing content, record identifiers
and canonical metadata are unchanged. Filtered listings retain their filters;
their existing canonical policy may still point to the unfiltered listing.
The calendar filter dropdown formerly appended `/#wyszukiwarka` to a URL that
already ended in `/`, producing `//#wyszukiwarka`. It now appends only the
fragment. Old calendar URLs with multiple final slashes redirect to a single
slash while retaining season, filters and query parameters. Internal repeated
slashes are not rewritten, as they can represent empty router parameters.
Query variants such as `/?preview=1` can still be reported as alternate pages
with a proper canonical tag. This change addresses missing-slash duplicates,
not every type of alternate URL.

## Link audit

The October 2026 source audit found public links without a final slash in the
cookie consent initialization (`application.js`), its default
(`cookie-consent.js`), and the Help button in `konto/moje_zajecia.php`. They now
link directly to `/home/polityka_prywatnosci/` and `/home/faq/` respectively.
Public navigation, detail cards, `Tagger`, course/waitlist email links and
sitemap generation already used final slashes. Legacy private action links
are outside the public canonical redirect policy. Editable content stored in
the database can contain older links; known public targets are covered by the
same redirect when opened.

## Group identity and retired events

`Event::getScheduleLabel()` formats the model's weekday and scheduled start time.
The controller passes that schedule label to the view and to `Seo::forEvent()`
along with the instructor label, category, location and event data.
Titles, descriptions and keywords distinguish the
instructor, season, weekday and scheduled start time. Descriptions remain
limited to 160 characters, with the identifying details preceding the location.
Each group retains its own canonical URL; parallel groups are not redirected
to another instructor's group. Social metadata uses the same title/description.

The detail view retains its existing category, instructor, location and season
tags and schedule section. It uses the model's schedule label for weekday/time,
escaped by the template. No extra heading or summary duplicates that information.
SEO separately sanitizes its metadata to plain text and returns only metadata;
it does not supply the view's schedule. Missing schedule information has a
readable fallback. Distinct metadata does not guarantee that Google will index
each parallel group separately; repeating existing visible facts adds no new
group-specific content.

`Tagger` handles null, empty, zero and nonexistent instructor identifiers using
`Instruktor nieprzypisany`. Such a label is not a profile link, and the group view
omits the missing instructor's thumbnail. Existing instructor links continue
to work. Tag text is HTML escaped. A successfully loaded empty instructor table
is cached as loaded instead of triggering repeated queries.

Legacy `special_event` records are retired from the public offer. The model's
`isPubliclyAvailable()` requires an active regular group, and calendar queries
exclude special events. This also excludes them from the sitemap, which uses
the calendar model. Their former detail URLs return the existing useful 404
page before rendering; the missing special-event template is no longer required.
The existing signup methods are unchanged. No records or registrations are
deleted and no `is_active` values are changed. Authorized management can still
inspect their history.

The local inventory on 2026-10-09 contained seven special groups, IDs 689–695,
dated 2021-04-30 through 2021-05-03 at Stadion Narodowy. Retirement is based on
the legacy flag, not hard-coded identifiers or dates. No migration or manual
server file operation is needed. The old method for fetching historical special
event data is retained for compatibility and has no public controller caller.

| Group ID | Historical category | Instructor |
| --- | --- | --- |
| 689 | Przedszkolak na rolkach | Karol Pałyga |
| 690 | Podstawy jazdy na rolkach dla dzieci | Kuba Klyha (Szczurowski) |
| 691 | Podstawy jazdy | Szymon Kubiak |
| 692 | Poziom średnio-zaawansowany | Maciek Gawłowski |
| 693 | Poziom zaawansowany | Michał Pytlak |
| 694 | Poziom zaawansowany | Łukasz Błaszczyk |
| 695 | Poziom średnio-zaawansowany | Ryszard Kopyciński |

All seven records had `is_active = 1` in the inspected local database. The public
retirement policy does not change those historical flags.

The legacy `/skate-cross-series-poland/` alias, with or without its trailing
slash, now redirects permanently to
`https://rollschool.pl/home/skate_cross_series_poland/`. Query strings are
preserved by the Apache rule. This follows the existing legacy-alias policy.

## Deployment and verification

Deploy as tracked code. No SQL migration, manual server file operation or local
configuration update is required. Verify on test before production:

1. Run `php tests/seo_trailing_slash_test.php`.
   Run `php tests/public_event_seo_test.php` and `php tests/event_validation_test.php`
   for group identity, missing instructors and special-event retirement.
2. GET and HEAD `/instruktorzy`, a public detail path without `/`, and a calendar
   filter path ending in `//` must return 301 with exactly one final slash
   before any query string. Follow the redirect and verify
   that the destination renders without another normalization redirect.
3. A calendar filter keeps every path parameter and query parameter.
4. POST to a public page and requests for files, `sitemap.xml`, `robots.txt`,
   account actions and payment callbacks bypass this redirect policy.
5. Verify the rendered cookie policy link, the account Help link and all
   calendar filter dropdown links (one slash before `#wyszukiwarka`). Public
   production canonical metadata and sitemap entries still use
   `https://rollschool.pl`; test remains blocked from indexing.
6. Compare two groups differing only by instructor, season or scheduled time:
   their titles and descriptions must differ while each
   canonical stays on its own URL. Verify the three reported pairs:
   2394/2392, 2327/2328 and 2315/2311.
7. An old special group such as 689 returns 404 without a PHP fatal error or a
   partial 200 page. Active regular groups still return 200. Missing instructors
   render a readable label without a broken profile link or image request.
8. Both old Skate Cross aliases return 301 to the current page and retain a
   sample query string. The current page returns 200.

Historical links continue working through redirects. Google needs to recrawl
them before Search Console updates their classification; old missing-slash
URLs may subsequently appear as pages with redirects rather than alternates.
Rollback restores the previous code and resumes serving both slash variants.
There are no data changes to reverse. Rolling back retirement would expose the
old missing-template branch again. Public FAQ instructions remain unchanged
because the user workflow has not changed.
