我有一个网站,可以让我通过 URL 中的查询访问该网站的移动版本。
我想不通的是如何自动将移动用户重定向到这个版本(目前你必须添加'?useformat = mobile'才能查看)。
这是我当前的 htaccess 设置
RewriteEngine On
#MediaWiki short URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#Mobile - not working?
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^([^/]*)$ /index.php?useformat=mobile&title=$1 [L]
#HTTPS redirect (site uses HTTPS)
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
对 mod_rewrite 来说有点新,之前没有做太多。