htaccess的重定向黑莓不工作

编程入门 行业动态 更新时间:2024-10-22 11:39:41
本文介绍了htaccess的重定向黑莓不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想通过做重定向黑莓用户到我的手机网站:

I am trying to redirect blackberry users to my mobile site by doing:

# redirect for blackberry users RewriteCond %{HTTP_USER_AGENT} ^.BlackBerry.$ RewriteRule ^(.*)$ www.domain/m/ [R=301]

在我的.htaccess,但是当我尝试从设备访问什么也没有发生,我已经删除缓存和COOKIS并没有什么作品。我一直在谷歌上搜索周围,似乎我是在做正确的重定向,但我想不会,我缺少什么?

in my .htaccess, but nothing happens when I try to access from the device, I've already deleted cache and cookis and nothing works. I have been googling around and it seems I'm doing the redirect correctly but I guess not, what am I missing?

我的.htaccess只​​包含的方式。

My .htaccess only contains that by the way.

修改 在我的服务器的根目录下的.htaccess。

Edit The .htaccess in my server's root.

推荐答案

如果这不是你的.htaccess文件中唯一的规则,你可能有一个问题,以后的规则搅乱你的重定向。要立即重定向,你需要包括→标记。

If this isn't the only rule in your .htaccess file, you might have an issue where a later rule messes up your redirect. To redirect immediately, you need to include the L flag.

我还怀疑你的正常的前pression用户代理可能是不正确的,你要测试对输入,由于两个。比赛刚一个字符的单词黑莓的任一侧。这也将是一个不错的主意,以防止重定向循环与检查,看看是否你已经在 / M / (但如果你有一个mod_rewrite的指令。在该目录中它并不重要)htaccess文件。

I also suspect that your regular expression for the user agent is probably not correct for the input you're testing against, since the two . match just one character on either side of the word "BlackBerry". It would also be a good idea to guard against a redirect loop with a check to see if you're already in /m/ (although if you have mod_rewrite directives in a .htaccess file in that directory it's not important).

把所有的一起,我们得到类似如下:

Putting all of that together, we get something like the following:

# Check for x-wap-profile/Profile headers RewriteCond %{HTTP:x-wap-profile} !^$ [OR] RewriteCond %{HTTP:Profile} !^$ [OR] # Check for BlackBerry anywhere in the user agent string RewriteCond %{HTTP_USER_AGENT} BlackBerry [NC] # Make sure we're not in /m/ already RewriteCond %{REQUEST_URI} !^/m/ RewriteRule ^ example/m/ [R=301,L]

您可能还需要该重写规则是

RewriteRule ^.*$ example/m/$0 [R=301,L]

...如果内容被命名为在 / M / 目录相同(但移动友好的)。

...if the content is named the same (but mobile-friendly) in the /m/ directory.

更多推荐

htaccess的重定向黑莓不工作

本文发布于:2023-10-31 13:02:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546163.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   黑莓   工作   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!