Milan Milosevic
Milan Milosevic

Reputation: 433

rewrite url, from subdomain to another subdomain

Im try find good solution to hide real streaming url, im try with php but have problems with stream in that way like

http://site.com/player/stream.php?p=[file path]&f=filename.flv&t=<? echo md5(session_id().$_SERVER['REMOTE_ADDR'])?>

Maybe rewrite url with htaccess is better solution? something like this

http://media.site.com/videos/0412/125843213/125843213.flv [org. file]

rewrite to

http://s1.media.site.com/0412/125843213.flv

.. any idea how to make this? or maybe is better to back on php...?

Upvotes: 0

Views: 93

Answers (2)

mbarlocker
mbarlocker

Reputation: 1386

In your htaccess file in the root directory, or from your apache configuration:

RewriteEngine On
RewriteBase /
RewriteRule ^videos/(\d+)/(\d+)/(\d+)\.flv$ http://s1.media.site.com/\1/\3.flv [R=301,L,QSA]

Having said that, once you have a rewrite, then your 'real url' that you want to hide has become the rewritten url. You will be able to access the file using either url. Basically, one of the urls to access the file will still be accessible by any users, so it's not any more secure.

Also, because of the host change, you will be sending 2 times the number of requests to your servers.

Good reasons to use rewrite:

  • SEO
  • Single entry point (like in CakePHP, CodeIgniter, etc - index.php)

Upvotes: 1

Frank
Frank

Reputation: 91

Would an iFrame to another PHP script on your server that handles these redirects using:

header("Location: $php_url_var");
exit;

or Javascript window.location work?

http://www.w3schools.com/js/js_window_location.asp

It seems like the simplest choice for what you're doing. If you're not familiar I can provide an example.

Upvotes: 0

Related Questions