我需要将使用移动用户代理的任何人重定向到名为 mobile.php 的文件。我的网络托管服务提供商 Net Registry 使用 Zeus 网络服务器。
这是我根据研究编写的脚本
RULE_1_START:
# get the document root
map path into SCRATCH:DOCROOT from /
match IN:User-Agent into $ with iPad|iPod|iPhone|Android|s+Mobile
if matched then
set OUT:Location = /mobile.php
endif
RULE_1_END:
我使用了主机站点上的说明。
我将其粘贴到他们的控制台中,它可以进行重定向。网络注册表有一些你提交的奇怪的控制台东西,更新 zeus 服务器配置需要 10 分钟(太烦人了)。
无论如何,我的问题是它会将我重定向到错误的位置:因此,如果您使用包含的用户代理字符串访问该站点,ipad|ipod|android|\s+mobile
那么您将触发它()
它把我带到这里:
http://example.com.au/mobile.php,%20catalog/index.php
我不知道如何解决这个问题,或者为什么会发生这种情况,因为目前这个文件存在:
http://example.com.au/mobile.php
和这个一样:
http://example.com.au/index.php. Contents of this file are:
<?php header("Location: catalog/index.php");
关于如何使这项工作更像 apache .htaccess url Rewrite 的任何想法?