Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

big_malk

macrumors 6502a
Original poster
Aug 7, 2005
557
1
Scotland
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!
 
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!

Add this to your .htaccess file

RewriteEngine on
RewriteCond %{http_host} ^address.com [nc]
RewriteRule ^(.*)$ http://www.address.com/$1 [r=301,nc]
Options All

Change "address" obviously.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.