AJAX, base href, and www. problems... need some suggestions

Discussion in 'Web Design and Development' started by big_malk, Aug 5, 2008.

  1. big_malk macrumors 6502a

    Joined:
    Aug 7, 2005
    Location:
    Scotland
    #1
    I'm making a website where people can play flash games and save high scores etc, I use AJAX to save (and load) the scores so they can save their score without interrupting their game. I also use mod_rewrite rules to give friendly urls.
    But, an example URL is http://www.standbygames.com/games/spacegame/, which appears to the browser to be in the /games/ folder, so I use <base href="http://www.standbygames.com/" /> so all the CSS etc that's in the root level loads, and that's also where the highscores page is loaded from via AJAX.

    Thing is, (in Safari and Firefox at least) if I you miss out the www. and goto, for example URL="http://standbygames.com/games/spacegame/"]http://standbygames.com/games/spacegame/[/URL], the browser seems to think it's loading from a different server and pops up a white box in the corner saying "Exception caught while loading insert_highscore.php?...: Permission denied".

    So I suddenly require everyone uses www. at the start of the address, or all the AJAX just stops working!
    I was wondering what I can do to best avoid this? I suppose I could use some mod_rewrite rule to force the www. to be there, but I'd rather not need to do that... and I don't know what rule to use that won't interfere with my other rules?

    Sorry if that wasn't explained very well, thanks for any help!
     
  2. mrzeve macrumors 6502a

    Joined:
    Jan 25, 2005
    #2
    Add this to your .htaccess file

    Change "address" obviously.
     
  3. big_malk thread starter macrumors 6502a

    Joined:
    Aug 7, 2005
    Location:
    Scotland
    #3
    Thanks that's a perfect solution!
     

Share This Page