简体   繁体   中英

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

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?

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");

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 (ie 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM