Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Special Interests > Web Design and Development
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread  
Old Aug 5, 2008, 01:16 PM   #1
big_malk
macrumors 6502
 
Join Date: Aug 2005
Location: Scotland
AJAX, base href, and www. problems... need some suggestions

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!
big_malk is offline   Reply With Quote
Old Aug 5, 2008, 02:15 PM   #2
mrzeve
macrumors 6502a
 
Join Date: Jan 2005
Quote:
Originally Posted by big_malk View Post
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

Quote:
RewriteEngine on
RewriteCond %{http_host} ^address.com [nc]
RewriteRule ^(.*)$ http://www.address.com/$1 [r=301,nc]
Options All
Change "address" obviously.
mrzeve is offline   Reply With Quote
Old Aug 5, 2008, 05:23 PM   #3
big_malk
Thread Starter
macrumors 6502
 
Join Date: Aug 2005
Location: Scotland
Quote:
Originally Posted by mrzeve View Post
Add this to your .htaccess file
...
Change "address" obviously.
Thanks that's a perfect solution!
big_malk is offline   Reply With Quote

Reply

Mac Forums > Special Interests > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:55 PM.

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 2002-2009, MacRumors.com, LLC