Is it possible to consider modification time (mtime) of file by mod_rewrite?
What I want to do is:
- when accessed to ‘*.html’:
- return ‘*.html’ when it exists and is newer than ‘*.html.eruby’.
- rewrite into ‘*.html.eruby’ when ‘*.html’ doesn’t exist or is older than ‘*.html.eruby’.
my .htaccess:
## inhibit direct access to *.eruby
RewriteRule \.eruby$ - [R=404,L]
## rewrite *.html into *.html.eruby when *.html.eruby exists
## (TODO: rewrite only when *.html.eruby is newer than *.html)
RewriteCond %{REQUEST_FILENAME}.eruby -s
RewriteRule ^(.*)$ $1.eruby
Of course there’s a solution. I sell it $100 000 000 (close friend’s price). Just kidding.
To solve this, use RewriteMap directive that executes an external “filter”. See here.
From the website, with emphasis on what you may look:
So my advice: make a very simple program in python that compares timestamps of the two files.
See here for a sample in Perl.