Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please help write some JavaScript - URL redirects with rewrites

    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:

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


    Caveats:

    1. 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.
    2. 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

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    Code:
    <script type="text/javascript" charset="utf-8">
    		Event.observe(window,'load',function(){
    			window.location='aychttp://www.goodblog.com//2008/09/crappy-name'			
    		});
    	</script>
    that would redirect them on page load i suppose... not sure if that's really what you're wanting.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •