View Full Version : How can I use .htaccess to force orphan pages to load with a different url?

07-06-2007, 07:30 PM
I use AJAX to load my pages into an iframe. You can get to them directly by putting the variables for the sections i am replacing. So if you go to www.thesmartass.info and click on games and then sega you will get to a sega genesis page. However I want people to be able to directly link to the page by going to www.themsartass.info/sega. I have setup my htaccess file to propertly redirect that page to load my content inside of the iframe. This works great but when a search engine sees my loose php pages it can load them directly. I want to force the referrer that loads those pages to come from my main page or rather make anybody who loads a loose page without my ajax or php load is forced to /sega or something instead.

sega.php loads by itselt, then reloads itself as www.thesmartass.info/sega .

if the request comes from either javascript that links to: <a href=javascript:ahah('games/loadsega.php);> or thesmartass.info/sega it will not redirect them.

Due to the nature of the ahah script I use I cannot use a javascript solution to do this since my javascript can't reparse javascript when it loads new content.

I can make .htaccess redirect one page to another page but I am unsure how to tell it to check to see if the referral came from my index page. I also need to ensure that nobody can link directly to my iframes without it forcing them to see entire page.