【发布时间】:2013-10-01 01:51:50
【问题描述】:
我已将我的站点 test.com 的域名更改为 test2.com
域名由test.com to test2.com更改
I want to know if all the pages like test.com/* will be redirected to test2.com/*
在 test2.com 中,我正在 mod_rewrite 中编写重写规则来识别智能移动设备。
For all smart phone I would like to redirect requests test.com/* to test2.com (home page)
For every non smart phone I would like to redirect test.com/* to test2.com/*
我为此研究了以下条件。我不确定这是否正确。
我已经尝试过这样的事情。
RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.com$ [AND]
RewriteCond %{HTTP_USER_AGENT} mobile
RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|iphone|ipod|windows phone) [NC]
RewriteRule ^(.*)$ http://test2.com/mobil/#1 [L]
【问题讨论】:
-
“对于所有智能手机,我想将请求 test.com/* 重定向到 test2.com(主页)” - 为什么? .当网站将我从深层链接(从论坛链接或搜索引擎中找到)重定向到他们的移动主页时,我非常讨厌它。我直接离开这些网站,再也没有回来。
标签: regex apache .htaccess http mod-rewrite