What would be the easiest route for creating permanent redirects to youtube based on user form input?

StackOverflow https://stackoverflow.com//questions/23025628

Question

Say I have a site, we'll say fakesitename.com. I want users to be able to fill out a form with five inputs:

  1. A Youtube video ID
  2. A start time
  3. An end time
  4. An alias
  5. A submit button

I'd like them to be able to submit this form, and for the site to create a redirect (preferably a 301 redirect, so I'm never technically hosting any content) from:

  • fakesitename.com/[[input4]]

to

  • Something like https://www.youtube.com/v/[[input1]]?hd=1&autoplay=1&start=[[input2]]&end=[[input3]]&version=3

What would be the best / easiest way to go about this? I'm not worried about handling the url layout generation, just writing the redirect.

Thanks for the help!

Was it helpful?

Solution

Well just use header to send a location header

header('Location: http://www.youtube.com/?blabla', true, 301);
exit;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top