Extension:MobileFrontend/Configuring browser auto-detection/zh

这个文档解释了站点管理员怎么样自动地启用插件，以便于为使用移动设备访问网站的用户重定向一个移动视图，而不是启用桌面视图.

内置自动检测
从提交5a1867e开始，MobileFrontend支持自动地设备检测，并且仅需要很少的配置. 所有你需要做的事情就是把以下代码：放到你的LocalSettings.php的文件中. 当然这是最简单的办法，他的性能也几乎是最低的. 这个解决方案不兼容开启了前端缓存的情况，因为这个方案无法让缓存知道移动视图和桌面视图的区别.

Apache Mobile Filter (AMF)
As of commit 0fb2c72d, MobileFrontend supports the Apache Mobile Filter (AMF) for device detection. 你使用的服务器必须是Apache服务器 按照如下的AMF配置步骤/设置，应该可以让你的需求运行起来. 这个函数和内置自动检测非常相似，并且没有特殊配置的话，也不兼容有前端缓存的方案.

Webserver/proxy-cache device detection
反向代理（如）可以告诉MediaWiki是否需要使用移动端页面，这样就可以创建对前端缓存友好的自动检测机制.

Detection using Varnish: mobile site on another domain
Suppose we use Varnish, and we want wiki.example.com to show desktop version, and m.wiki.example.com to show mobile version. Here is how to do that.

LocalSettings.php should contain the following:

If you have many wikis, it may be convenient to use syntax like:

Where "%h<#>" maps to a segment of the hostname of. So, if, %h0 is "en", %h1 is "wikipedia", %h2 is "org". Given this, the above will automatically interpolate your mobile URL as "en.m.wikipedia.org". This is particularly useful for the WMF and projects like Wikipedia, which follow a template of, so the mobile domain will always look like.

Detection using Varnish: same domain for desktop/mobile site
Suppose we use Varnish, and we want wiki.example.com to show desktop/mobile version on the very same URLs (without creating additional domains like "m.wiki.example.com", etc.). Here is how to do that.

Otherwise MobileFrontend misbehaves (if we don't set $wgMobileUrlTemplate, it ignores X-WAP header, if we do, it doesn't set "useformat" cookies for "toggle Mobile view' links in the footer").