.htaccess重写导致无限循环

问题描述 投票:1回答:1

我有一个.htaccess代码,可以将智能手机上的每个用户重定向到兼容的网站:

RewriteEngine On
RewriteEngine On
RewriteCond %{QUERY_STRING} !^desktop
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteRule ^ http://logo.artliner.co.il//mobile.html%{REQUEST_URI} [R,L]

此代码导致无限循环,如下所示:http://logo.artliner.co.il//mobile.html/mobile.html/mobile.html/mobile.html/mobile.html/mobile.html/mobile.html/

你能帮我解决这个问题并停止循环吗?谢谢!

.htaccess loops url-rewriting
1个回答
0
投票
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} !^desktop
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteRule !^mobile.html$ /mobile.html [R,L]

只有在请求URI模式不完全符合RewriteRule时才会应用mobile.html

© www.soinside.com 2019 - 2024. All rights reserved.