Is there any way to make it so that trying to go to a file in certain directory will redirect you to the appropriate page that has it? Basically, people have been linking directly to my .swf files instead of the pages they're on. It's hurting my bandwidth without getting any site exposure. So, for example, say they're trying to go to /games/play_me.swf ... is there any way to make it so that trying to go directly to that file sends you to /play_me.php instead?
Put this in your .htaccess file: Redirect /games http://flashcoin.com/ Code (markup): ...or whatever the paths are. The template is: Redirect /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html Code (markup): It also works with just directories: Redirect /olddirectory/ http://yoursite.com/newdirectory/ Code (markup): Hope this helps! -Peter
Now here's the money question... is there any way to make it point to the appropriate game page. For instance, games/number1.swf should point to number1.php and games/number2.swf should point to number2.php and so on?
Put this in the .htaccess file of the directory containing the .swf files: RedirectMatch 301 (.*)\.swf$ http://www.flashcoin.com/newfolder/$1.php Code (markup): This takes every request for a file in that directory and redirects it to the new location, changing the .swf extension to .php.
That's exactly what I'm looking for. However... unfortunately... I just realized I'd have to change a major part of my script in order for this to work properly. The pages' file names on my site are based on the title of the game, not the swf file. Before I spend hours of work on this... is there any way to integrate SQL database info into a .htaccess file? I know I'm probably pushing it now. Thanks for all your help so far.
I'm 99% sure there's not. I know close to nothing about SQL and little about .htaccess (I'm just good with Google). Maybe you could devise a script to rename all the pages for you based on the embedded .swf file? Can you do that with SQL? Just be sure to back everything up.
Only problem I have with that is that all the links I have pointing to a specific game on my site from other places will have absolutely no value.
Just tested that and it ruins the site completely. The pages that have the swf's on them won't load them at all. I'd assume since the server is trying to get a file from that directory, it's getting the redirect.
Want a really simple fix? Put this in the .swf folder's .htaccess file: <files "*.*"> Deny from All </files> Code (markup): This pretty much says "If you're not FlashCoin.com, go away." Now if a user tries to directly access a game, they get an error that says forbidden. If your site tries to access one, it's allowed. I'm sure there's a way to tie this into a redirect, I just haven't found it yet. -Peter