Very specific redirection question

Discussion in 'HTML & Website Design' started by IXM, Nov 7, 2006.

  1. #1
    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?
     
    IXM, Nov 7, 2006 IP
  2. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #2
    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
     
    dp-user-1, Nov 7, 2006 IP
  3. IXM

    IXM Peon

    Messages:
    213
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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?
     
    IXM, Nov 7, 2006 IP
  4. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #4
    That's a tough one. I'll see what I can do.
     
    dp-user-1, Nov 7, 2006 IP
  5. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #5
    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.
     
    dp-user-1, Nov 7, 2006 IP
  6. IXM

    IXM Peon

    Messages:
    213
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    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.
     
    IXM, Nov 7, 2006 IP
  7. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #7
    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.
     
    dp-user-1, Nov 7, 2006 IP
  8. IXM

    IXM Peon

    Messages:
    213
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    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.
     
    IXM, Nov 7, 2006 IP
  9. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #9
    Then I would say just redirect the user to the homepage? Sorry - I'm out of suggestions.
     
    dp-user-1, Nov 7, 2006 IP
  10. IXM

    IXM Peon

    Messages:
    213
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #10
    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.
     
    IXM, Nov 7, 2006 IP
  11. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #11
    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
     
    dp-user-1, Nov 7, 2006 IP