View Full Version : Please help write some JavaScript - URL redirects with rewrites

Mr Brainz
09-10-2008, 12:57 PM
Hi there,

I hope someone can help me.

I'm porting a blog from an extrememly restrictive provider onto a self-hosted solution. I don't want to lose bookmarked direct traffic and inbound links. The trouble is the restrictive blog provider doesn't allow server-side scripting or access to .htaccess files.

I've come up with an ingenious way of redirecting the traffic using a find and replace feature on the blog provider. I just need a script that will do the trick.

I need to:

Take the URL the page is on... (aychttp://blogname.swagblogs.com/my_weblog/2008/09/crappy-name.html)
...and replace the base with my new domain... (aychttp://www.goodblog.com/2008/09/crappy-name.html)
...then lose the .html extension... (aychttp://www.goodblog.com//2008/09/crappy-name)
...then send the browser onto the new URL


I intend to replace instances of </p> with <script type="text/javascript" src="scriptname.js"></script>, so really I need the script to still work when there are multiple instances of it on the same page.
The .html extension may not always be present

Can anyone help me please? I realise this is cheeky but I'm at my wit's end with this crappy blog hoster and I regret ever going with them!

Thanks in advance

09-10-2008, 04:42 PM
<script type="text/javascript" charset="utf-8">

that would redirect them on page load i suppose... not sure if that's really what you're wanting.