Redirect all domains requests to 1 domain without `www.` on Divshot

319 views Asked by At

Kicking the tires on divshot.com with my middleman blog. I moved it over from Heroku, which uses rack to handle URL redirects/rewriting. I'm trying to duplicate some of that behavior on divshot, which uses HTML5 pushState (superstatic) instead.

I have multiple domains that I want to redirect to 1 domain, and I want to redirect all www. requests directly to http://example.com (rather than http://www.example.com).

Is there anyway to do this?

2

There are 2 answers

2
Michael Bleigh On BEST ANSWER

there are a few ways to tackle this:

  1. Your DNS provider may offer the ability to make these kinds of redirects without having to use Divshot to do it.
  2. If you have a high-performance app (i.e. a paid plan) we can manually configure our CDN to do those redirects for you.
  3. You can detect host in JS and redirect that way (less ideal, I'd go with 1 or w).
0
GibboK On

In order to redirect a user to another page, you can use:

if(window.location.host === 'www.example.com') {
    window.location = "http://example.com";
}

or for IE only:

window.navigate("http://www.example.com");