This question is somewhat similar to "Unpublishing" a Language from a site

We've built a new site for a client that has 6 languages. The default language is English (en). They want to go live with just the English site, and restrict access to the other languages on content delivery environments. However, their content authors on their CM sites still need to work on these language versions and preview/publish them on the authoring site.

I'm looking for a way to restrict access to these non-english languages without removing them from the web db. My attempt at a quick fix was to replace the LanguageResolver on CD only with a class that forces Context.Language to English. That worked, but the language parts of the url still resolve. So /en/my-page and /de-DE/my-page resolve to the same item. I'd like the non-english language urls to 404.

This will be a temporary measure until they choose to go live with their localized versions so ideally I'd like to be able to remove this easily.


  • You can make use of a NotFoundProcessor in the httpBeginRequest. If you see that the context language is not en, then redirect to 404 Mar 22, 2017 at 21:54
  • This sounds like the path of least resistance. I'm going to give it a try. Thanks! Mar 23, 2017 at 13:56
  • @HishaamNamooya I wound up implementing your suggestion, it's working great. If you want to post it as an answer I'll mark it accepted. Mar 28, 2017 at 12:20
  • I have added the answer @Chris Mar 28, 2017 at 12:38

4 Answers 4


You can make use of a NotFoundProcessor in the httpBeginRequest. If you see that the context language is not en, then redirect to 404. A code snippet example is shown below:

public class NotFoundProcessor : HttpRequestProcessor
    protected HttpRequestArgs Args { get; set; }

    public override void Process(HttpRequestArgs args)
        Assert.ArgumentNotNull(args, "args");

        this.Args = args;

        if (!Context.Language.Equals("en"))
            //Write a method which gets the 404 page
            Context.Item = GetError404Item()
            var link = LinkManager.GetItemUrl(Context.Item);
            HttpContext.Current.Server.TransferRequest(string.Format("~/{0}?status=404", link.TrimStart('/')));

One option would be to set Languages.AlwaysStripLanguage = false in config settings.

This would cause the Sitecore.Pipelines.PreprocessRequest.StripLanguage processor in the preprocessRequest to not try and resolve any languages embedded in the URL and instead trying to match them as content in the tree. If you don't have items named en or de-DE in the tree then this will in turn throw a 404.

You may also want to set languageEmbedding = never in the LinkManager, and only set these values on the CD servers.

When you're ready to go live then remove/revert the above settings.

If you want to keep the en part in the URL then you could create a custom StripLanguage processor to only interpret specific languages.


A temporary workaround that I've used in the past is to use URL Rewrite module for IIS and setup 302 (temporary) redirects for any request coming in that isn't for english. You capture the url portion for the language of the incoming request and then swap it to 'en'.

You can then update your redirect rules as you release additional languages.


Did you consider just setting up full language sites on the CM for previewing/prepublishing purposes?

Not to answer a question with a question; basically what I am proposing is, a setup like this:

  • Mark the undesired languages as unpublishable
  • This should keep them out of "web"
  • Leave the sites active in configuration on Content Management server
  • Run them in "live" mode (straight from "master")
  • Configure alternative host names and have these point to the CM server
  • Bind the hosts on CM server IIS

The benefit would be; this requires no code change. And also has the benefit of giving you a full "preview" site anyone can browse to for approvals, without having to log into Sitecore.

  • I tried unpublishing the languages, and marking Never Publish to True on them. However, the language versions of the items are still available in the front ends if I swap /en/ to /de-DE/ for example. I see the German version. I can remove all the language versions in web but I can't guarantee the authors won't publish them again inadvertently. Mar 23, 2017 at 12:28
  • Hrmf. It shouldn't do that :/ I'll try and set up an instance later today, see if I can spot the reason.
    – Mark Cassidy
    Mar 23, 2017 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.