Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为站点的移动版本使用.htaccess文件_.htaccess_Jquery Mobile_User Agent - Fatal编程技术网

为站点的移动版本使用.htaccess文件

为站点的移动版本使用.htaccess文件,.htaccess,jquery-mobile,user-agent,.htaccess,Jquery Mobile,User Agent,我做了一个jQuery移动站点。我想把这个目录上传到原始站点的FTP中。现在我只想在移动设备中检测移动站点。这就是为什么只能在移动设备中打开移动版本的原因。 就像我有我的网站url www.example.com,它应该在桌面网站中打开。 另一个站点意味着移动站点应该在www.example/mobile-site中打开 我发现了这样的检测手机版本的文档 # don't apply the rules if you're already in the mobile directory, infi

我做了一个jQuery移动站点。我想把这个目录上传到原始站点的FTP中。现在我只想在移动设备中检测移动站点。这就是为什么只能在移动设备中打开移动版本的原因。 就像我有我的网站url www.example.com,它应该在桌面网站中打开。 另一个站点意味着移动站点应该在www.example/mobile-site中打开

我发现了这样的检测手机版本的文档

# don't apply the rules if you're already in the mobile directory, infintine loop
# you'll want to test against the host if you're using a subdomain
RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
# if the browser accepts these mime-types, it's definitely mobile, or pretending to be
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]
# a bunch of user agent tests
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ /mobiledirectoryhere/ [L,R=302]
我将“MobileDirectory”更改为我的移动版本站点目录“mobile”。之后,我将文件上传到FTP,并将其重命名为.htaccess


我浏览了参考网站
http://ohryan.ca/blog/2010/04/10/how-to-detect-mobile-visitors-using-htaccess-rewrite-rules-simplified/

我找到了一个简单的站点检测解决方案。只需使用以下内容将
.htaccess
文件添加到根目录

RewriteEngine on
RewriteCond %{HTTP_HOST} !^m\.myurlname\.com$
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^/?(.*)$ http://m.myurlname.com/$1 [L,R=302]

然后保存它。

抱歉,我使用了该代码,但它不起作用。它有什么作用吗?什么不起作用?你得到状态码了吗?说明书上写着,移动目录应该写在“mobiledirectoryhere”的位置,我写了,但它不起作用。