.htaccess 当dns更改完成时,旧重定向会发生什么情况

.htaccess 当dns更改完成时,旧重定向会发生什么情况,.htaccess,mod-rewrite,redirect,dns,.htaccess,Mod Rewrite,Redirect,Dns,我在我的网站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.ht

我在我的网站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]

您需要添加检查
%{HTTP\u HOST}
变量的条件:

# For mobile devices:
RewriteCond %{HTTP_HOST} !^mobile\.test\.nu$ [NC]
RewriteCond %{HTTP_USER_AGENT} (android|blackberry|iphone|ipod|windows\ phone) [NC]
RewriteRule ^ http://mobile.test.nu/ [L,R=301]

# For non-mobile devices:
RewriteCond %{HTTP_HOST} ^mobile\.test\.nu$ [NC]
RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|iphone|ipod|windows\ phone) [NC]
RewriteRule ^/?$   http://test.nu/mobil/index.htm [L,R=301]

RewriteCond %{HTTP_HOST} ^mobile\.test\.nu$ [NC]
RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|iphone|ipod|windows\ phone) [NC]
RewriteRule ^(.*)$ http://test.nu/mobil$1 [L,R=301]
不完全清楚你的规则应该做什么,因为我认为上面的规则行不通。但本质上是:

RewriteCond %{HTTP_HOST} ^mobile\.test\.nu$ [NC]

将告诉您该请求是否适用于
mobile.test.nu

谢谢您的回答。我想,我可以按照你的建议识别主机并编写规则。请帮助我检查它们是否正确规则是否不正确。我编辑了我的问题。即使在dns更改之后,我是否能够使用RewriteCond%{HTTP_host}^mobile\.test\.nu$[NC]@Patan捕获原始主机?你说的“原始”主机是什么意思?
%{HTTP\u HOST}
变量是
http://host/path/request
URL@Patan
表示“不匹配”,没有
,表示它必须匹配