Is there a way to rewrite


to something smaller?

or is there a way to change this into


What can i do?


i've tried with something like this:

header('Content-type: application/x-shockwave-flash');
header('Content-Length: ' . filesize($file));
header('Connection: close');
$video_id = $_REQUEST['id'];
$content = readfile("http://localhost/embed/player.swf?file=http://www.youtube.com/watch?v=$video_id");
echo $content;

but it is mot working.

what i am doing wrong?

3 Answers 3


Try something like the following in the .htaccess file (create it if it doesn't already exist) in your website's root directory:

RewriteRule ^embed/player.swf?file=([0-9a-zA-Z0-9]+) embed/player.swf?file=http://www.youtube.com/watch?v=$1 [L]
  • Note that this internally rewrites the "short" URL back to the "long" URL. The "long" URL still needs to be changed to the "short" URL in the application itself.
    – MrWhite
    Dec 10, 2015 at 12:12

it should be possible with either method; I'll post a possible PHP solution.


This is a very simplified solution, so you would still have to handle filtering your input, escaping output, and empty IDs if you wanted to use it in a production environment.

  • is there anybody knowing how to resolve this problem?
    – m3tsys
    Mar 7, 2011 at 12:02

Try the simple and easy solution no need to specify headers

<?php if ($_REQUEST['id']): ?> // youtube video id

<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/<?php echo $_REQUEST['id']; ?>" frameborder="0">

<?php endif; ?>
  • Very strange, to come up with an IFRAME, if someone asks for a mod_rewrite solution.
    – feeela
    Jul 5, 2011 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.