URL Pattern
A URL pattern is a template for web addresses: instead of a single fixed address, it describes a whole group of similarly structured addresses. Programs use such patterns to recognize which page is meant and which information is contained in the address.
Every page on the internet has an address, for example example.com/article/42. Such addresses are called URLs. Many addresses on a website are structured the same way and differ only in a few places. A URL pattern is the template behind this: a description of the fixed parts and the variable parts. For our example, it might read /article/:id. The colon marks the spot where any number may stand.
Why websites don’t consist of millions of individual pages
A large news site quickly accumulates hundreds of thousands of articles. Nobody creates hundreds of thousands of files for this. Instead, there is a single template and a pattern that covers all article addresses. The server recognizes from the pattern that article 42 is meant, fetches the text from a database and assembles the page. Without a pattern, such a page would be practically impossible to operate.
Patterns also make addresses predictable. Anyone who knows /article/42 can guess that /article/43 also exists. This helps search engines, developers and automated programs alike. Rules can also be formulated concisely with them: a firewall can block all addresses under /admin/ without knowing each individual one.
A common misconception: a URL pattern does not guarantee that the page exists. The pattern only states how an address may look. Whether article 999999 exists is decided only by the database. If no address matches a known pattern, the server delivers the familiar 404 error message.
Fixed parts, placeholders and the order of the rules
A pattern consists of fixed pieces of text and placeholders. The word article, for instance, is fixed, while the number after it is variable. Two notations for placeholders are common: :id or in curly braces. An asterisk or two dots often stand for any number of further path segments. When an address matches a pattern, this is called a match.
During a match, the variable spots are read out and passed to the program. So from /article/42, the value id equals 42 is derived. This process is called routing, because the request is directed to the matching part of the program. You can imagine it like a mail sorting facility: the postal code is the fixed part, the house number the variable one.
Usually several patterns exist at the same time, and they are checked one after another. The first one that matches wins. That’s why the order matters: if the general pattern /article/:id comes before the specific /article/new, even a call to new ends up at the article lookup. Such mistakes are among the classic pitfalls. Strictly speaking, URL patterns are a simplified form of regular expressions, i.e. general text patterns — just deliberately made easier to read.
From the address bar to the programming interface
Patterns are most visible in the browser’s address bar. In an online shop, all product pages look structurally the same; on a video platform, all channel pages do. Redirects are also based on this: if a company moves, it can redirect all old addresses to the new ones with a single rule.
In the world of technology, URL patterns appear everywhere programs talk to each other. A programming interface, or API for short, almost always describes its functions as patterns like /v1/users/. Anyone building a weather app reads exactly such lines in the documentation. Web frameworks, i.e. construction kits for websites, also largely consist of such route lists.
In AI and tech news, patterns are mainly encountered on the topic of access rights. Operators use rules to define which address ranges an AI provider’s crawler may read and which it may not. Paywalls and blocklists likewise work with patterns instead of individual addresses. Modern browsers now come with a built-in feature called URLPattern, so that all programs understand the same notation.