-
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?
-
Re: Rewritting URLs
you mean, somthing like i have don here ?
http://youtubehits.freehostia.com/
:D
-
Re: Rewritting URLs
no. I need the video.php page to load the video
-
Re: Rewritting URLs
so dclam
You want to give the url like this
Quote:
mysite/video.php?14323
I have given like this youtubehits.freehostia.com/index.php?topic=google_earth
what is the diffrent between us?
-
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...
-
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").