使用Apache RewriteRule和RewriteCond将替代内容设置到特定日期

使用Apache RewriteRule和RewriteCond将替代内容设置到特定日期,apache,mod-rewrite,osx-server,Apache,Mod Rewrite,Osx Server,我需要在特定日期之前提供一个正在建设中的页面,但在新内容需要显示的那一天,以及之后的一周半(我知道,第一世界的问题…)我将离开这个国家 我目前在httpd-vhosts.conf文件中提供的是正在构建的页面 RewriteRule ^(.*)$ \ http://localhost:8080/VirtualHostBase/\ http/%{SERVER_NAME}:80/under_construction/VirtualHostRoot$1 [L,P] 下面是我想使用的,但我不完全理解它应

我需要在特定日期之前提供一个正在建设中的页面,但在新内容需要显示的那一天,以及之后的一周半(我知道,第一世界的问题…)我将离开这个国家

我目前在httpd-vhosts.conf文件中提供的是正在构建的页面

RewriteRule ^(.*)$ \
http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/under_construction/VirtualHostRoot$1 [L,P]
下面是我想使用的,但我不完全理解它应该如何工作,当然,它不能正常工作,因为它没有正确配置。我尝试过更改时间字符串,以便在重新启动几分钟后更改它,但配置可能不适合开始

RewriteRule ^(.*)$ \
RewriteCond ^{TIME} < 201304220000
http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/under_construction/VirtualHostRoot$1 [L,P]

RewriteRule ^(.*)$ \
RewriteCond ^{TIME} > 201304220000
http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/content/VirtualHostRoot$1 [L,P]
RewriteRule^(.*)$\
重写cond^{TIME}<201304220000
http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/under_construction/VirtualHostRoot$1[L,P]
重写规则^(.*)$\
重写条件^{TIME}>201304220000
http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/content/VirtualHostRoot$1[L,P]

我至少在正确的轨道上吗?另外,除了localhost:80/server status之外,还有什么方法可以从终端查看Apache的状态(日期、时间等)?任何帮助都将不胜感激

您需要在将其应用于以下规则之前使用
RewriteCond

RewriteCond %{TIME} < 20130422000000
RewriteRule ^(.*)$ http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/under_construction/VirtualHostRoot$1 [L,P]

RewriteCond %{TIME} > 20130422000000
RewriteRule ^(.*)$ http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/content/VirtualHostRoot$1 [L,P]
RewriteCond%{TIME}<20130422000000
重写规则^(.*)$http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/under_construction/VirtualHostRoot$1[L,P]
重写cond%{TIME}>20130422000000
重写规则^(.*)$http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/content/VirtualHostRoot$1[L,P]

%{TIME}
变量是4位数的年、2位数的月、2位数的日期、2位数的小时、2位数的分钟和2位数的秒。

在将其应用于以下规则之前,您需要
重写cond

RewriteCond %{TIME} < 20130422000000
RewriteRule ^(.*)$ http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/under_construction/VirtualHostRoot$1 [L,P]

RewriteCond %{TIME} > 20130422000000
RewriteRule ^(.*)$ http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/content/VirtualHostRoot$1 [L,P]
RewriteCond%{TIME}<20130422000000
重写规则^(.*)$http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/under_construction/VirtualHostRoot$1[L,P]
重写cond%{TIME}>20130422000000
重写规则^(.*)$http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/content/VirtualHostRoot$1[L,P]

%{TIME}
变量是4位数的年、2位数的月、2位数的日期、2位数的小时、2位数的分钟和2位数的秒。

比较运算符和

RewriteCond%{TIME}=20130422000000
重写规则^(.*)$\
http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/content/VirtualHostRoot$1[L,P]

另外,不要忘记使用
=
在比较运算符和

RewriteCond%{TIME}=20130422000000
重写规则^(.*)$\
http://localhost:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/content/VirtualHostRoot$1[L,P]

另外,不要忘记使用
=
出于某种原因,每当我将RewriteCond%{TIME}>20130422000000添加到https-vhosts.conf文件时,我都会收到一个错误:“Safari无法连接到服务器”。如果我删除重写条件,它将恢复正常。我尝试过更改日期/时间,但仍然没有更改。抱歉,httpd-vhosts.conf出于某种原因,每当我将RewriteCond%{time}>20130422000000添加到https-vhosts.conf文件时,我都会收到一个错误:“Safari无法连接到服务器”。如果我删除重写条件,它将恢复正常。我已尝试更改日期/时间,但仍然没有更改。抱歉,httpd vhosts。请不要忘记日期本身,请使用
=
。否则,您将脱机一天。我仍然会遇到下面提到的错误。每当我向规则添加重写条件时,浏览器都无法连接到服务器。无论是否有第二条规则,都会发生这种情况。不要忘记当天本身,请使用
=
。否则,您将脱机一天。我仍然会遇到下面提到的错误。每当我向规则添加重写条件时,浏览器都无法连接到服务器。无论是否有第二条规则,都会发生这种情况。经过几次测试后,这项功能现在可以工作了。非常感谢你!但是,我尝试了一些特定的时间来测试它是否正确更改,并且>=导致了错误。如果我只是简单地将在建时间改为20130422000000,那么它似乎会在该时间发生变化而不会跳过。我尝试了20130417124000,12:40刷新后,内容切换得非常完美。再次感谢!经过几次测试后,这项技术现在可以使用了。非常感谢你!但是,我尝试了一些特定的时间来测试它是否正确更改,并且>=导致了错误。如果我只是简单地将在建时间改为20130422000000,那么它似乎会在该时间发生变化而不会跳过。我尝试了20130417124000,12:40刷新后,内容切换得非常完美。再次感谢!