我想显示一个即将到来的网页给所有的访问者一个网站。但是为了测试的目的,如果某个查询字符串被添加到URL中,我想显示真实的网站。
RewriteCond %{QUERY_STRING} !(^|&)backdoor=1($|&)
RewriteCond %{REQUEST_FILENAME} !coming-soon
RewriteRule ^.*$ /coming-soon.html [L]测试用例:
。
更新:
我发现所有PHP文件在上面的脚本中都失败了。静态文件工作:
/test.php --> coming-soon.html
/test.php?backdoor=1 --> 404
/test.txt --> coming-soon.html
/test.txt?backdoor=1 --> shows the content of the file correctly此外,我还发现,如果我不使用QUERY_STRING条件,而是使用REMOTE_ADDR,一切都能工作(但我仍然希望检查查询字符串,而不是IP):
RewriteCond %{REMOTE_ADDR} !123.123.123.123$
RewriteCond %{REQUEST_FILENAME} !coming-soon
RewriteRule ^.*$ /coming-soon.html [L]发布于 2019-09-22 06:37:59
你可以试试这条规则:
ErrorDocument 404 default
RewriteEngine On
RewriteCond %{QUERY_STRING} !(^|&)backdoor=1($|&) [NC]
RewriteRule !^coming-soon\.html$ coming-soon.html? [L,NC]目标中的?将在重写后去掉?backdoor=1,因此重写的URI只是/coming-soon.html (没有查询字符串)。
发布于 2019-09-27 17:47:26
10年前,我认为服务器级的重定向工作太多了。除此之外,它们很难登录,也很难测试。
既然这是暂时的,为什么不直接在应用程序级别这样做呢?只需在php中编写一个简单的if/ Just语句?
https://stackoverflow.com/questions/57991651
复制相似问题