RegEx和Apache重写让我发疯! [英] RegEx and Apache rewrite making me crazy!

查看:132
本文介绍了RegEx和Apache重写让我发疯!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名前C ++程序员,现在担任经理并利用我的技能在网页设计等方面跛行。我们的网站运行得很好,但我真的绊倒一些Apache重写代码重定向到我们的移动网站。



我们想将www.domain.org和domain.org重定向到m.domain.org(Google和Bing的链接需要无主机版本。)我们还在移动页面上有一个完整站点按钮,可以将人们发送到www.domain.org。这是代码:



I''m a former C++ programmer now employed as a manager and using my skills to limp along in web design, etc. Our site is running pretty well but I''m really stumbling over some Apache rewrite code to redirect to our mobile website.

We want to redirect both www.domain.org and domain.org to m.domain.org (the hostless version is needed for links from Google and Bing.) We also have a "full site" button on the mobile page that sends folks to www.domain.org. Here''s the code:

# prevent looping
RewriteCond %{HTTP_HOST} !^m\.

# a bunch of user agent tests
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile}       !^$

# rewrite rules here
RewriteRule ^(.+)\$ http://m.animalhealthassociates.org/$1 [R=302,NC] // This does not redirect animalhealthassociates.org
# RewriteRule ^ http://m.animalhealthassociates.org/ [R=302,NC] // This redirects the above but also redirects the Full Site link





我会我坦率地承认我对正则表达不太了解,而且我目前的情况不允许我花时间去获取完全理解这一点的知识。为了满足这两个要求,我还需要做什么?



I will freely admit I don''t know much about regular expressions, and my current situation does not allow me to take the time to gain the knowledge to fully understand this. What on earth do I need to do to meet both requirements?

推荐答案

[OR]
RewriteCond%{HTTP_USER_AGENT}android | blackberry | iphone | ipod | iemobile | opera mobile | palmos | webos | googlebot-mobile[NC,OR]
RewriteCond%{HTTP:Profile}!^
[OR] RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR] RewriteCond %{HTTP:Profile} !^


#rewrite rules here
RewriteRule ^(。+)\
# rewrite rules here RewriteRule ^(.+)\


http://m.animalhealthassociates.org/
http://m.animalhealthassociates.org/


这篇关于RegEx和Apache重写让我发疯!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆