Online course platforms often face issues with duplicate content when both 'www' and non-'www' versions of a domain are accessible. This guide outlines how to resolve this by implementing permanent redirects (HTTP 301) to standardize the canonical URL structure, ensuring better SEO performance and user consistency.

Understanding the Need for Domain Unification

This is a hypothetical example rather than a recommendation list. Picture an independent instructor who sells a single recorded course and has drafted a one-page launch checklist in a notebook. The page has three column headings: "Item," "Preferred address," and "Redirect from." The author fills them with self-invented entries to think through the problem before touching any configuration.

The first row reads: Item: course overview page; Preferred address: http, host "learnwithsam", path "/overview"; Redirect from: same host with the "www" prefix. The second row: Item: enrollment form; Preferred address: http, host "learnwithsam", path "/enroll"; Redirect from: the "www" variant of the same path. A third row covers the FAQ sheet: preferred address at the apex host with path "/faq", redirect from the "www" host's matching path. These are the author's own labels, written for personal clarity; the spelling "learnwithsam" is simply how the notebook records it, not a claim about what any registration or search field will accept.

The author also sketches two candidate names for the course site itself: "Sam Teaches Science" and "Science Notes by Sam." Neither is a brand decision yet. The point of writing both is to notice that whichever name wins, the address problem is identical: two host spellings can serve the same pages, and the checklist needs one preferred column and one redirect-from column so the author stops typing both variants into handouts and slide decks.

Then comes one explicit trade-off. The author considers pointing everything at the "www" host instead of the apex. Reason for choosing the apex preferred address: short printed links on a workbook page are easier to read and to dictate in a classroom, and the notebook already has fewer characters to recheck in each row. The corresponding explanation is that the "www" spellings are listed only in the redirect-from column, so the author has a single rule to apply per item rather than a per-link decision.

These entries are worked examples the author constructed to explain the problem to themselves. They are not a record of any past site, real learner feedback, or a completed setup, and the rows say nothing about how any particular hosting or redirect tool will behave. Their only job is to make the duplication visible: a course page, a form, and an FAQ sheet each need one preferred address and one redirect source written down before the next step.

The Role of HTTP 301 Status Codes

The 301 status code is the mechanism the draft checklist points to for sending visitors from one host form to the other. MDN’s reference defines HTTP 301 Moved Permanently as a redirection response indicating the requested resource has permanently moved to the URL given in the Location header. A browser that receives this status automatically requests the resource at that Location URL, which is how a visitor arriving at one address is passed to the other.1

The same reference states that search engines receiving a 301 attribute links to the original URL to the redirected resource, passing the SEO ranking to the new URL. That is the documented basis for treating the redirect as more than a cosmetic host change.1

One caveat in the reference concerns request methods: when a user agent receives a 301 in response to a POST request, it uses GET in the subsequent redirection request, and MDN suggests 308 Permanent Redirect where the method should not be altered.1

You can treat the status code as a note to yourself about intent, not just a switch to flip. In your notebook, add a narrow fourth column, "What this redirect tells me," and write a plain sentence for each row. For the overview page it might read: this row says every visitor who types the www prefix should end up at the same overview page I chose as primary. That sentence keeps the reason visible when you revisit the list weeks later.

When two rows disagree, the written reasons help you choose. Suppose the overview row points to the apex host while the checkout row points to the www host. You might rewrite both entries so every public page lands on the same host, then note in the column that the change exists to keep one address per page rather than two competing ones. If you prefer the opposite direction, keep the entries consistent and record that choice instead.

For the course title "Sam Teaches Science," you can decide separately whether it belongs in the notebook at all; a redirect row concerns addresses, not names. The useful habit is to let each row carry one address decision and one short reason, so a later reader of your own notes can tell which pages you meant to unify and why.

Configuring Permanent Redirects in Middleware

Microsoft's ASP.NET Core URL Rewriting Middleware documentation describes three options for sending non-www requests to the www subdomain: AddRedirectToWwwPermanent redirects a non-www request permanently using status 308, while AddRedirectToWww uses status 307 for a temporary redirect, and an overload lets you supply the response status code through fields of the StatusCodes class. These are the documented www-directed options; the page notes no equivalent built-in apex option.2

For a custom rule, AddRedirect takes a .NET regular expression matching the incoming URL path, a replacement string, and an optional status code. If no status code is specified, it defaults to 302 Found. A rule such as a path pattern replaced by a redirected path captures the trailing segments and injects them into the replacement through $1, and the redirect URL is sent to the client with the stated status code.2

The documentation warns that redirect rules are evaluated on every request, including redirected requests, so an infinite redirect loop is easy to create by accident. It also states that when request-derived text can control the complete destination, construct a scheme prefix, or determine the host, the rule is unsafe, and recommends a fixed local prefix for in-app redirects or a fixed host or allow-list validation for external ones.2

You can start by grouping your notebook entries into two sets before writing a single redirect note. Take every row already marked with a preferred address and a redirect-from address, then copy them onto a fresh page under the heading “move now.” Rows that still carry an undecided name or a missing preferred host go on a second page marked “hold.” A launch checklist with six course-page rows might split four to two. The four settled rows can guide middleware configuration; the two held rows are simply waiting.

Once the move-now page feels complete, you can draft the pattern each row should follow in plain words. One row might read: match an incoming www request for the overview path, then send it to the same path on the apex host with a permanent status. Write that sentence once and reuse its shape for the other settled rows. If a second row concerns a checkout page rather than the overview page, keep the host and status the same but change the path, so the difference is visible at a glance.

You might then check the move-now page against your course page names one final time. Where a page title and an address note seem to overlap, consider leaving the title on the hold page; the redirect sheet only needs addresses.

Implementing AddRedirectToWwwPermanent

In ASP.NET Core, RewriteOptionsExtensions.AddRedirectToWwwPermanent permanently redirects a request to the www subdomain when the request is non-www. The Microsoft.AspNetCore.Rewrite API documentation lists two overloads: one takes a RewriteOptions instance, and the other adds a domains string array that limits the rule to apply only on the specified domain or domains. Both overloads return RewriteOptions.3

This reverses the apex-preferred setup discussed above: the rule as documented moves non-www requests toward www, not the other way. The documentation covers the method's behavior, parameters, and return value only; it does not describe how to wire the rule into an application's request pipeline. Note also that the page carries Microsoft's prerelease disclaimer, warning that some information may change before release.3

For the next pass over your launch checklist, you can turn the three-column page into a working note and leave the site configuration untouched for now. Take each row and add a short line directly beneath it describing the one request you intend the redirect to catch: for the course overview row, that line might read "incoming www request for the overview page should arrive at the apex version." You can do the same for the checkout row and any other page you have already listed, using whatever preferred address you chose.

Where a row still feels uncertain, consider marking it with a question you can answer later rather than deciding now. For instance, if you are not yet sure whether the welcome page belongs in the set, write "decide whether this page moves with the apex or stays on www" beside it, and leave the redirect line blank until you choose. That way the checklist keeps your open choices visible without forcing a premature commitment.

You might also add a small closing note at the bottom of the page explaining, in one sentence of your own, why the apex address is the one you prefer for this course site. That sentence is for you as much as anyone: when you return to the notebook months later, it will remind you which direction the redirects were meant to run and why you set them that way.

Verifying Redirect Behavior and Headers

In the Microsoft.Aspnetcore.Rewrite API, the AddRedirect overload that takes options, a regex, and a replacement returns a 302 status code when the request matches the HttpContext's PathString. A separate overload adds an Int32 statusCode parameter, described as the status code to add to the response, so a caller can supply 301 instead of relying on the default. In both overloads, the regex string is compared with the request's path, and the replacement string determines what to replace the URI with if the regex matches.4

These documented signatures cover path matching and status selection only. The page does not describe verifying an actual response after deployment, inspecting returned headers, or confirming that a www request reaches the apex host.4

You can begin by choosing one page from your launch checklist and writing a short verification note beside it, in your notebook, that records what you would look for once the redirect is live. Keep it hypothetical for now. For the overview row, you might jot: request the www address, expect a permanent redirect, and note which host appears in the final address.

The useful part is separating the pieces you can observe from the ones you cannot yet. You can watch whether the www request resolves to the apex address and whether the page content loads as expected. You might leave a gap for the status code itself, marked as something to confirm later, rather than writing a number you have not seen.

Consider treating the response headers as a second small column on this page. Against each checklist row, you can note the header name you intend to inspect and what you hope it tells you, such as whether the redirect looks permanent rather than temporary. That note keeps the intent readable without pretending the check already happened.

If the overview and checkout rows disagree about which host is preferred, your verification note can carry both expectations side by side. You might write, for the overview, "expect apex" and, for checkout, "expect www," then leave a line explaining which one you intend to change. This way the notebook shows the question, not a settled answer.

Best Practices for Course Site Owners

You can put your launch checklist to work by adding one narrow column, “Name or address?”, and sorting each row before you touch anything technical. A course overview page belongs in the address set; a tagline such as “Sam Teaches Science” belongs in the name set. Keep the two sets on separate pages so a naming debate never blocks a redirect decision. You might write the question beside each row in your own words: does this entry point somewhere, or does it describe something?

For every address row, you can draft the plain-language rule in one sentence and then test it against a second, imagined request. If the row says the www form of the overview page should lead to the apex form, write the incoming and target addresses in full natural text, then read them aloud. When the sentence sounds tangled, consider shortening it rather than adding detail. This is where a filled example helps: item “course overview,” preferred address at the apex host with path “/overview,” redirect from the same host and path with the “www” prefix.

You can also give each row a small status word of your own choosing, such as “agreed,” “leaning,” or “open.” For an open row, write the single question that would settle it, for example whether the preferred host should be repeated on the checkout page. If two rows lean in different directions, you might place them side by side and write one sentence about which choice keeps the site easier to explain. That sentence is a note to yourself, not a rule for anyone else.

Before saving the page, you can read three rows in sequence and check one thing only: does each preferred address use the same host as its neighbours? If one row stands apart, mark it rather than changing it, and decide later which way it should go. A short closing note at the bottom, in your own words, can record which host you currently favour and why, so a future revision has something concrete to compare against.

Frequently asked questions

How can I turn my three-column launch checklist into a working note without changing site configuration?

For the next pass over your launch checklist, you can turn the three-column page into a working note and leave the site configuration untouched for now. Take each row and add a short line directly beneath it describing the one request you intend the redirect to catch: for the course overview row, that line might read "incoming www request for the overview page should arrive at the apex version."

If a row in my notebook still feels uncertain, how can I mark it instead of deciding now?

Where a row still feels uncertain, consider marking it with a question you can answer later rather than deciding now. For instance, if you are not yet sure whether the welcome page belongs in the set, write "decide whether this page moves with the apex or stays on www" beside it, and leave the redirect line blank until you choose.

How can I give each row in my notebook a small status word and record what would settle an open row?

You can also give each row a small status word of your own choosing, such as “agreed,” “leaning,” or “open.” For an open row, write the single question that would settle it, for example whether the preferred host should be repeated on the checkout page.