我有一个移动网站,我将其与名片上的二维码结合使用。目前,当我将我的主要网站置于维护状态时,我使用 503 重定向到 maintenance.php。但这也排除了移动网站。我想要实现的是,在维护模式下仍然可以访问我的移动网站以及该目录 (/qr/) 中的所有文件和文件夹。此外,我想将访问者重定向到我的移动名片,并向他们显示一条消息,表明他们正在访问替代网站。
我的移动名片位于 mydomain.com/qr/。我在 <body>
之后添加了这个我的/qr/index.php 的标签:
<?php if(isset($_GET["maintenance"])) {
header('HTTP/1.1 503 Service Temporarily Unavailable');
echo '<div class="maintenance">Our website is currently undergoing maintenance. You are now viewing our mobile business card as a substitute. Our apologies for any inconvenience, we will be back shortly.</div>';
}
else{}
?>
所以我希望我的 503 错误页面是 mydomain.com/qr/?cp=xxxxx&maintenance
(我需要 cp
来处理其他事情)。
在我尝试过的其中一件事中,我在根文件夹中将以下内容设置为我的 .htaccess:
RewriteEngine On
Alias /qr/index\.php "/qr/index.php?cp=xxxxx&maintenance"
RewriteCond %{REMOTE_ADDR} !^xxx\.xxx\.xxx\.xxx$
RewriteCond %{REQUEST_URI} !/qr/$
RewriteCond %{REQUEST_URI} !\.(css|png|vcf)$
RewriteRule .* /qr/index\.php [L]
但是我收到了 500 内部服务器错误。我在某处读到 /path/to/503.php
需要使用别名,因此我有理由这样做。
我哪里做错了,我怎样才能达到我想要的结果?
干杯,
网络小 Sprite
最佳答案
使用错误文档有什么问题?
ErrorDocument 503 /qr/index.php?cp=xxxxx&maintenance
关于php - htaccess 中的自定义 503 页面为 "/path/to/index.php?maintenance"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22136164/