Time lock for mod_rewrite in .htaccess file

喜夏-厌秋 提交于 2020-01-05 21:20:33

问题


I have question:

RewriteCond %{HTTP_USER_AGENT} (safari|navigator) [NC]
RewriteCond IF SOMEONE ASK, IN LESS THAN 30 SECONDS (HALF MINUTE) FOR FILES IN FOLDERS  (folder1|folder2|folder3) 
RewriteRule ^((?!folder3/).*)$ /folder3/$1 [L,NC]

Perhaps more simplified:

RewriteCond IF SOMEONE ASK, IN LESS THAN 30 SECONDS (HALF MINUTE) FOR FILES IN FOLDERS  (folder1|folder2|folder3) 
RewriteRule ^((?!folder3/).*)$ /folder3/$1 [L,NC]

If someone ask (some browser) apache http server for files in folder1 and folder2 in less than 30 seconds but than ask for files in folder3 after that period of time ex. (in 45 seconds or 2 minutes) than rewriterule won't be executed. Files from all three folders must be reqested in less than 30 seconds in order to rewriterule work it's job.


回答1:


Answer to this question is unfortunately: "no, you can't do it in .htaccess"

There is no available variable in mod_rewrite that lets you access the file modification/creation time and write conditions agains it.

See full list of mod_rewrite variable

Only option is to forward the request to a PHP controller and do this check inside PHP code.



来源:https://stackoverflow.com/questions/21984945/time-lock-for-mod-rewrite-in-htaccess-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!