John Smith
John Smith

Reputation: 6207

Prevent a file to access if for .htaccess: DirectoryIndex

if might be very weird question. I have this:

DirectoryIndex index.php wait.php

the rule is the following: load index.php, the normal site if everything is OK. But in case is a cache is being rewrited, load the wait.php, which consits a "page will loads in some seconds, be patient".

Im trying to lock the index.php:

$f = fopen('index.php', 'r');
flock($f, LOCK_EX | LOCK_NB);
sleep(10); // so cache is beign writed

and when this file ends, lock will be nullified. But this idea doesnt work: I cant open the index.php in Total Commander BUT from another browser appache will load index.php. So its not locked from it after all.

Upvotes: 0

Views: 28

Answers (1)

Matthew Knight
Matthew Knight

Reputation: 631

DirectoryIndex will only try the next file in the list if the previous file is missing.

Your index.php is not missing, it's simply locked.

You should use your index.php to handle the logic of which file to use, or could even use another script to move or rename the index.php whilst it is being cached.

Upvotes: 2

Related Questions