Tuesday, January 11, 2011

How to Display Youtube Videos on Pages with SSL

So there is a pretty neat trick everyone should be aware of, if you have a site using SSL.

As I am sure you are aware, if you post anything referencing 'http://' on a page using SSL, Internet Explorer will display a wonderful little message to your clients basically telling them you are trying to destroy their lives with your evil insecure page.

In order to avoid mass panic, there is a simple way to fix this problem on your server.

Just add the following lines to your sites .htaccess file :

RewriteEngine On
RewriteRule ^youtube/(.*)$ http://www.youtube.com/$1 [L]

Now you can reference youtube videos like this:

       
   <param name='movie' value='https://www.yoururl.com/youtube/v/querystuff'>
   </param>
   <embed src='https://www.yoururl.com/youtube/v/querystuff' type='application/x-shockwave-flash' width='400' height='300'>
   </embed>


Just a quick FYI, this method will only work on an apache server with mod_rewrite enabled.

No comments:

Post a Comment