Set alternate content until a specific date with A

2019-08-20 03:38发布

I need to serve an under construction page until a specific date, but I will be out of the country on the day the new content needs to display, and for a week and a half after (I know, first world problems...)

What I currently have serving the under_construction page in my httpd-vhosts.conf file.

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

What I would like to use is below, but I don't fully understand how it should work, and of course it isn't working properly because it isn't configured properly. I have tried changing out the time string to get it to change a few minutes after the restart, but the configuration is probably not right to begin with.

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]

Am I at least on the right track? Also, besides localhost:80/server-status, is there any way to see the status of Apache (date, time, etc.), from Terminal for instance? Any help would be greatly appreciated!

2条回答
ゆ 、 Hurt°
2楼-- · 2019-08-20 03:54

You need the RewriteCond before the rule that it is applied to:

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]

The %{TIME} variable is the 4 digit year, 2 digit month, 2 digit date, 2 digit hour, 2 digit minute, and 2 digit second.

查看更多
Root(大扎)
3楼-- · 2019-08-20 03:59

Spaces are not allowed between the comparison operator and the CondPattern

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]

Also don't forget to use >= or <=, depending on whether you want to switch on that day or a day later.

查看更多
登录 后发表回答