MShack
MShack

Reputation: 652

Redirect all pages except a few specific ones

I need to use javascript on this, and place in header for all site pages.

//.mysite.com - redirect all pages within this domain to //.mysite.com/home

Except for these 3 page examples, I don't want these redirected.

www.mysite.com/page2 
www.mysite.com/article/sat
www.mysite.com/home/message

Any ideas? I've never had a request for something like this.

Upvotes: 0

Views: 46

Answers (1)

Guig
Guig

Reputation: 10169

if (['/page2', 'article/sat', 'home/message', '/home'].indexOf(window.location.pathname) < 0)
    window.location = 'www.mysite.com/home'

no need for jquery

Upvotes: 1

Related Questions