Results 1 to 6 of 6

Thread: Rewritting URLs

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Rewritting URLs

    I am creating a videos page, and i need to display a video on the page, but i dont want to put the actual URL to the video. I want something like:

    mysite/video.php?14323

    and it will somehow rewrite the url in video.php to show the video... any thoughts on how to do this?
    My usual boring signature: Something

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Rewritting URLs

    you mean, somthing like i have don here ?
    http://youtubehits.freehostia.com/
    Last edited by Fazi; Sep 30th, 2007 at 07:20 PM.

  3. #3

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Rewritting URLs

    no. I need the video.php page to load the video
    My usual boring signature: Something

  4. #4
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Rewritting URLs

    so dclam

    You want to give the url like this

    mysite/video.php?14323
    I have given like this youtubehits.freehostia.com/index.php?topic=google_earth

    what is the diffrent between us?

  5. #5

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Rewritting URLs

    I think i explained wrong. I am embedding songs/videos on my website and i dont want the actual URL of the media to show, so i want to some how play it through another url.

    Ex: here is the actual url of a file:
    http://www.mysite.com/path/to/file.mp3

    instead of showing that in my source, i want to show:
    media.php?id=some_rand_hash

    and in media.php, it does a mysql lookup, gets the actual url, and plays it... somehow.

    I am going to try something with Headers...
    My usual boring signature: Something

  6. #6
    New Member
    Join Date
    Oct 2007
    Posts
    4

    Re: Rewritting URLs

    Code:
    <?php
    
    $id = intval($_GET['fileid']);
    // look up the file where id = $id
    $file_path = get_file_path($id);
    // perhaps set your mime-type here based on the file extension
    // header("Content-type: audio/mpeg");
    readfile($file_path);
    
    ?>
    readfile will stream the file out for you, so http://yoursite/file.php?fileid=2 would return the file stream as if you requested it directly from the filesystem.

    make sure you send the content-type in the header too. some browsers need this or else it won't display your youtube video, image, or mp3 file. you can base that off of you file extensions (ex: me.mp3 translates to "Content-type: audio/mpeg" and a png image would be "Content-type: image/png").
    Last edited by Mad-Hatter; Oct 11th, 2007 at 12:14 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width