PDA

View Full Version : youtube.com/v/fo_acb123 -- How do they get this redirect to work?


kgosser
01-29-2008, 05:17 PM
Hey everyone,

I'm trying to figure out a better way to provide my site's embeddable snippets. When I was researching YouTube's method, I noticed that they don't link to an actual .swf file and pass params in, but rather simply link to a directory. Here's an example:


<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/fo_QVq2lGMs"></param>
<param name="wmode" value="transparent"></param>
<embed
src="http://www.youtube.com/v/fo_QVq2lGMs"
type="application/x-shockwave-flash"
wmode="transparent" width="425" height="355">
</embed>
</object>


The key part is the http://www.youtube.com/v/fo_QVq2lGMs.

I would be interested in some feedback as to how one would return this data. Is it just a redirect script going on (via the language of your choice)? So it does some sort of redirect to http://www.youtube.com/v/player.swf?config=QVq2lGMs ?

If anyone has any experience, I'd love to hear how you tackled it! Thanks.

CyanBlue
01-29-2008, 05:29 PM
I am sure there are million ways of handling that... But if I were to do that, I'd create a server side script that parses the parameter(fo_QVq2lGMs) portion from the URL, query the database, get the valid URL to the SWF/FLV pair with that data, and then redirects the user to the right URL to display the video...

kgosser
01-29-2008, 05:45 PM
Do I need to declare the content type (applications/x-shockwave-flash) anywhere?

CyanBlue
01-29-2008, 05:48 PM
Inside the PHP script where you need to spit out the SWF player, I presume... ;)

kgosser
01-29-2008, 06:05 PM
Cyan, a couple replies have come back from some other friends, and they all say to use an .htaccess method. Would you recommend that instead?

CyanBlue
01-29-2008, 06:09 PM
Um... If it is a normal redirect, I'd say .htaccess on Apache would be the perfect solution, but I disagree on this specific case because you have to translate http://domain.com/abc to come up with http://domain.com/video/123.swf where you cannot simply translate abc to 123.swf without the help of a database... But that method would work if you can live with http://domain.com/video/abc.swf where you can using the parameter as a file name... Know what I mean???

Oh, it's CyanBlue not Cyan... ;)

kgosser
01-29-2008, 06:15 PM
My fault, duly noted :)