I’m trying to redirect users from one site to another but keep the part after the domain name the same. For example:
http://www.mysite.com/this-is-a-blog-post.html
to
http://www.newwebsite.com/this-is-a-blog-post.html
Can this be done using a javascript redirect? If so, what would the code look like? I appreciate your help!
Check out the
window.locationobject. If you just want to change the domain (keeping the same path) use this code.window.location = "http://newwebsite.com/" + window.location.pathname;If you want to do anything more sophisticated, you can mess with the
window.location.pathnamevalue and use that to redirect.