【发布时间】:2014-02-05 14:05:41
【问题描述】:
我的站点 mobil.test.nu 有一个重定向规则。
# For mobile devices:
RewriteCond %{HTTP_USER_AGENT} (android|blackberry|iphone|ipod|windows\ phone) [NC]
RewriteRule ^ http://test.nu/ [L,R=301]
# For non-mobile devices:
RewriteRule ^/?$ http://test.nu/mobil/index.htm [L,R=301]
RewriteRule ^(.*)$ http://test.nu/mobil$1 [L,R=301]
一些请求正在重定向到 test.nu。
我正在将 mobil.test.nu 的 dns 更改为 test.nu。
我想我必须在 test.nu 中重新重写所有来自 mobil.test.nu 的请求。
有人可以告诉我如何在 dns 更改后识别来自 mobil.test.nu 的请求。
编辑 识别主机名并进行修改。
# For mobile devices:
RewriteCond %{HTTP_HOST} ^mobile\.test\.nu$ [NC]
RewriteCond %{HTTP_USER_AGENT} (android|blackberry|iphone|ipod|windows\ phone) [NC]
RewriteRule ^ http://test.nu/ [L,R=301]
# For non-mobile devices:
RewriteCond %{HTTP_HOST} ^mobile\.test\.nu$ [NC]
RewriteRule ^/?$ http://test.nu/mobil/index.htm [L,R=301]
RewriteRule ^(.*)$ http://test.nu/mobil$1 [L,R=301]
【问题讨论】:
标签: .htaccess mod-rewrite redirect dns