每次在PHP中提供具有动态名称的相同视频或文件

I have a video. Suppose it's name is sample.mp4

But I want it to be served as another dynamic and non repeated name.

For example:

data-videomp4="assets/video/sample.mp4"

should be like this

data-videomp4="assets/video/123456789.mp4"

OR

data-videomp4="assets/video/any_RANDOM_NAME.mp4"

File should remain only one. I can copy files at different name at run-time but that will not be wise to do.

So I need something like a dynamic ROUTE which will be linked to single file always.

File size is always less than 10 Megabytes.

I'm not sure of the rewrite rules Codeigniter applies by default and how they may or may not conflict with this, but fundamentally all you want is to make your web server serve one specific file regardless of what URL is being accessed. To do this in Apache, you place a file called .htaccess into the assets/video/ folder with this content:

RewriteEngine on
RewriteRule ^ sample.mp4

^ simply matches any request and substitutes it with sample.mp4. See https://stackoverflow.com/a/20563773/476.

Try to generate symlinks (shortcuts) on-the-fly, should be fast operation :

<?php

$real_file = 'sample.mp4';

// generating new symbolic link (shortcut)
$rnd_name = md5(random_bytes(100)) . '.mp4';
$cmd = "ln -s {$real_file} {$rnd_name} 2>&1";
$rez = shell_exec($cmd);

// check for errors - for example, no write permission for apache user by default
if ($rez !==null) {
  var_dump($rez);
  exit;
}

echo "<a href='{$rnd_name}' 
         target='blank'>{$rnd_name}
      </a><br><br>
     <video id='myVideo' src='{$rnd_name}' controls='true'>
     </video>";

// don't forget to unlink (delete) created symlinks after some time

?>