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重定向到移动站点,但需要排除一个目录_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

.htaccess HTACCESS重定向到移动站点,但需要排除一个目录

.htaccess HTACCESS重定向到移动站点,但需要排除一个目录,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我使用下面的htaccess代码将移动设备上的任何人重定向到网站的移动版本,但我需要排除文件夹统计信息 我该怎么做 RewriteBase / # Check if this is the m=no query string RewriteCond %{QUERY_STRING} (^|&)m=no(&|$) # Set a cookie, and skip the next rule RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S] #

我使用下面的htaccess代码将移动设备上的任何人重定向到网站的移动版本,但我需要排除文件夹统计信息 我该怎么做

RewriteBase /
# Check if this is the m=no query string
RewriteCond %{QUERY_STRING} (^|&)m=no(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]
# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile}       !^$
#Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} ^(?:www\.)?website\.co.uk$
#Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=no(&|$) 
#Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]
#Now redirect to the mobile site
RewriteCond %{REQUEST_URI} !\.(?:gif|jpe?g|png|pdf)$ [NC] 
RewriteRule ^ http://m.website.co.uk%{REQUEST_URI} [R,L]

根据您所展示的规则,请您尝试以下操作。如果您正在查找一个从
stats
开始的uri,则在以下规则中从
stats
更改为
^/stats

RewriteEngine ON
RewriteBase /
# Check if this is the m=no query string
RewriteCond %{QUERY_STRING} (^|&)m=no(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]

# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile}       !^$
#Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} ^(?:www\.)?website\.co.uk$
#Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=no(&|$) 
#Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]
#Now redirect to the mobile site
RewriteCond %{REQUEST_URI} !\.(?:gif|jpe?g|png|pdf)$ [NC] 
RewriteCond %{REQUEST_URI} !stats [NC]
RewriteRule ^ http://m.website.co.uk%{REQUEST_URI} [R,L]

看到你的个人资料就知道你没有接受任何问题的答案,在答案不多的时候给它一些时间,检查它们,然后回复给用户它是如何进行的。为了感恩,你可以投票选出所有有用的答案(鼓励用户这么做),并从中选出一个答案。你可以看到这个链接:干杯,快乐学习。现在,您也可以转到旧答案,并可以在任何适用的地方接受答案,干杯。请确保在测试URL之前清除浏览器缓存。