0

I need to be abled to change all links without a domain name to a selected domain name with javascript.

Here are some links:

<a href="/home">Home</a> // Will be changed to blog.etree.biz/home when clicked.

<a href="externaldomain.com/post.html">Source</a> // Wont be effected.

Basicly i want all internal links to be changed to have the current domain attached.

This may seem pointless so i'll explain:

The blog use to be hosted via www.etreeblog.com. Now it is hosted via blog.etree.biz.

The provider of www.etreeblog.com has a redirection service, but it does not redirect it embeds the webpage in it's domain. However when you are viewing the page via www.etreeblog.com and you click an internal link or add a path you get an error message saying 'Path not found on this server'.

So when a link is clicked i need it to take them to the new domain, not the same place on the old domain.

Edit: The redirection from the old provider is embedding my site in a frame. How can a redirect my site from the frame to the real site?

Austin Collins
  • 439
  • 3
  • 13

2 Answers2

1

If you can't get your provider to fix the redirect, look into the base tag.

<base href="http://blog.etree.biz/">
jgillich
  • 71,459
  • 6
  • 57
  • 85
  • Updated my question, could you take another look? The base tag is not working because the website is in a frame. – Austin Collins Feb 19 '15 at 16:22
  • @AustinCollins What kind of frame? iframe? – jgillich Feb 19 '15 at 16:26
  • @AustinCollins Yeah I just noticed, well that one has been deprecated for a while: https://developer.mozilla.org/en/docs/Web/HTML/Element/frame – jgillich Feb 19 '15 at 16:31
  • Not only is the page in an iframe, it appears the the page with the iframe has the meta tags `` that's not good. Who's your provider? Are they a hosting provider or just a domain registar? – Robert Dundon Feb 19 '15 at 16:37
  • @RobertDundon Just a domain registrar. – Austin Collins Feb 19 '15 at 18:58
  • @AustinCollins So why can't you just change the way the "redirect" works? The real problem here is that using an deprecated HTML tag is causing tons of problems. Just go into your webserver config and set a 301 redirect, problems solved. – jgillich Feb 19 '15 at 19:06
  • @jgillich It's a cheap provider, it's the only option available. We use it reserve brandable domains before we transfer them to another registrar. – Austin Collins Feb 19 '15 at 19:12
  • @AustinCollins So you can't even put a [HTML page](http://stackoverflow.com/questions/5411538/redirect-from-an-html-page) on the old domain? – jgillich Feb 19 '15 at 19:24
  • I could point it to a free page like Tumblr or Blogger. However there is not much point in me doing that if I wish not to use the domain anymore. – Austin Collins Feb 19 '15 at 19:28
0

For a quick and dirty solution, you can do a redirect using JavaScript:

if(window.location.href === "http://www.etreeblog.com/") {
    window.location = "http://blog.etree.biz/";
}

Note that search engines won't run this and might even punish the new domain for duplicate content.

jgillich
  • 71,459
  • 6
  • 57
  • 85