Why /page and /page/ are two URLs, but the root is one
The root is a single URL
RFC 3986 says that for http URLs an empty path is equivalent to /, so a bare domain and the domain with a slash are the same URI. For the root URL, Google treats https://example.com and https://example.com/ as the same, and one cannot be redirected to the other.
Below the root, two URLs
Google permits different content on the slash and non-slash versions, but says this is often less ideal for users. When the non-slash URL redirects to the trailing-slash URL, Google says its results will likely show the version that returns 200, whether the redirect is 301 or 302.
Relative links
A relative link resolves from the last slash of the base path, so adding or dropping a trailing slash moves its target. One reason Apache adds the slash to directory URLs is so that relative links inside the HTML resolve correctly.
Server and framework defaults that add or strip the slash
Apache and Next.js handle the slash differently.
Apache directories. Apache's
mod_dirredirects a request for a directory without a trailing slash to the same URL with the slash added. TheDirectorySlashsetting is on by default in Apache. Apache warns that turning off the trailing slash redirect can expose directory listings.Apache, other URLs. For URLs that are not real directories, or to remove slashes, Apache documents
mod_rewriterules.Next.js. By default Next.js redirects URLs with a trailing slash to the version without it. Setting
trailingSlash: trueinnext.config.jsreverses this, so/aboutredirects to/about/.
A move from one stack to the other can change the form of every URL. Google recommends choosing one preferred version and 301-redirecting the duplicate to it (rel="canonical" as a fallback). In a 2010 post, Google said you can choose either form but should be consistent and use the preferred version in internal links. The same post says a sitemap should list only the preferred version, not the duplicate URL.
For Next.js routing choices, see the App Router vs Pages Router comparison.
How Pagepro keeps the slash convention in a migration
On a WordPress migration or any other replatform, Pagepro matches the old site's URL conventions to the character, trailing slashes included. The new stack's defaults do not get to change every URL.
Sources
- To slash or not to slash (Google Search Central Blog, 2010)Google · developers.google.com
- RFC 3986: Uniform Resource Identifier (URI): Generic SyntaxIETF · rfc-editor.org
- Apache Module mod_dir (DirectorySlash)Apache Software Foundation · httpd.apache.org
- Redirecting and Remapping with mod_rewriteApache Software Foundation · httpd.apache.org
- next.config.js: trailingSlashVercel (Next.js) · nextjs.org