/    Sign up×
Community /Pin to ProfileBookmark

Make a movie the default file in a directory!

Hi. I have a directory called movie.my-domain.com. I have an MPEG in the directory and want to make it the default file i.e. it is the file loaded when the directory opens. Can I do this with PHP. I am using Apache 1.3.33/PHP 4.3.11 but have no access to PHP or Apache config. Also .htaccess is disabled.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJun 13.2005 — well, you could redirect to it using a meta refresh tag in html
<meta http-equiv="refresh" content="0, URL=http://movie.your-domain.com/movie.mpg">
Copy linkTweet thisAlerts:
@AdamGundryJun 13.2005 — The elegant way to do this is to use the Apache [url=http://httpd.apache.org/docs/mod/mod_dir.html#directoryindex]DirectoryIndex[/url] directive, but that requires access to the Apache configuration or a .htaccess file. Failing that, you can use a redirect as LiLcRaZyFuZzY suggests but I would recommend a server-side redirect rather than client-side. You could use the following PHP code in an index file:

header("Location: http://movie.example.com/movie.mpg");

Adam
Copy linkTweet thisAlerts:
@Brain_StormauthorJun 13.2005 — Neither of those answers are much help. Instead of using forwarding I could just as well link to the file like this movie.my-domain.com/movie.mpg but that is exactly what I am trying to avoid.

Thanks for the effort anyway.

Anyone else got any suggestions?
Copy linkTweet thisAlerts:
@bokehJun 13.2005 — That sounds simple enough. Save the following in the 'movie' directory. Name it index.php and fill in the filename and path at the top.
[code=php]
<?php

// Get variables
$movie = 'movie.mpg'; // Fill in path and filename
$last_modified = date("D, d M Y H:i:s GMT", filemtime($movie)); // Date last modified
$movie_size = filesize($movie); //File size must be sent
$headers = apache_request_headers(); // Get headers sent from client browser

if(isset($headers['If-Modified-Since'])){ // If file not modified since last viewing don't send it
if($last_modified == $headers['If-Modified-Since']){
header("HTTP/1.x 304 Not Modified");
}
}else{ //Send the file along with correct headers
header("Content-Type: video/mpeg"); // This header must be sent with an MPEG file
header("Content-Disposition: inline"); // This is to try to make it play in the same window
header("Accept-Ranges: bytes"); // This header must be sent with an MPEG file
header("Content-Length: $movie_size"); // This header must be sent with an MPEG file
header("Last-Modified: $last_modified"); // Used to check if file has been modified since first sent to the client
@readfile($movie); // Read the file and send it to the client
}

?>
[/code]
×

Success!

Help @Brain_Storm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...