Apache-如何检查TestString是否是htaccess中的有效URL?

Apache-如何检查TestString是否是htaccess中的有效URL?,apache,.htaccess,Apache,.htaccess,我正在尝试检查测试字符串是否是有效的远程url,并找到了-U条件 关于中的-U条件 “-U”(是现有URL,通过子请求)检查是否 TestString是一个有效的URL,可通过服务器的所有 当前为该路径配置的访问控制。这使用了 内部子请求执行检查,因此请谨慎使用-它可以 影响服务器的性能 以下两个条件都重定向到hello.php RewriteCond ^http://google.com$ -U RewriteRule ^.* hello.php?test=true [L] RewriteC

我正在尝试检查测试字符串是否是有效的远程url,并找到了
-U
条件

关于中的
-U
条件

“-U”(是现有URL,通过子请求)检查是否 TestString是一个有效的URL,可通过服务器的所有 当前为该路径配置的访问控制。这使用了 内部子请求执行检查,因此请谨慎使用-它可以 影响服务器的性能

以下两个条件都重定向到hello.php

RewriteCond ^http://google.com$ -U
RewriteRule ^.* hello.php?test=true [L]

RewriteCond ^google$ -U
RewriteRule ^.* hello.php?test=true [L]
RewriteCond ^localhost$ -U
RewriteRule ^.* hello.php [L]

RewriteCond ^http//localhost$ -U
RewriteRule ^.* hello.php [L]

RewriteCond ^?localhost$ -U
RewriteRule ^.* hello.php [L]
RewriteCond ^http://localhost$ -U
RewriteRule ^.* hello.php [L]

RewriteCond ^:localhost$ -U
RewriteRule ^.* hello.php [L]
关于
-U
真正在做什么的信息很少

Q1-是检查本地URL还是远程URL

问题2-是请求URL还是解析URL

已编辑

重定向到hello.php

RewriteCond ^http://google.com$ -U
RewriteRule ^.* hello.php?test=true [L]

RewriteCond ^google$ -U
RewriteRule ^.* hello.php?test=true [L]
RewriteCond ^localhost$ -U
RewriteRule ^.* hello.php [L]

RewriteCond ^http//localhost$ -U
RewriteRule ^.* hello.php [L]

RewriteCond ^?localhost$ -U
RewriteRule ^.* hello.php [L]
RewriteCond ^http://localhost$ -U
RewriteRule ^.* hello.php [L]

RewriteCond ^:localhost$ -U
RewriteRule ^.* hello.php [L]
不重定向到hello.php

RewriteCond ^http://google.com$ -U
RewriteRule ^.* hello.php?test=true [L]

RewriteCond ^google$ -U
RewriteRule ^.* hello.php?test=true [L]
RewriteCond ^localhost$ -U
RewriteRule ^.* hello.php [L]

RewriteCond ^http//localhost$ -U
RewriteRule ^.* hello.php [L]

RewriteCond ^?localhost$ -U
RewriteRule ^.* hello.php [L]
RewriteCond ^http://localhost$ -U
RewriteRule ^.* hello.php [L]

RewriteCond ^:localhost$ -U
RewriteRule ^.* hello.php [L]

简而言之,它通过向指定的资源发出HTTP HEAD请求来完成上述所有工作


HEAD请求响应中的状态代码用于确定资源的可访问性和状态。

要使
-U
返回true:

RewriteCond ^localhost$ -U
RewriteRule ^foo index.php?test=true [L,QSA]

要使
-U
返回false:

RewriteCond ^http://localhost$ -U
RewriteRule ^foo index.php?test=true [L,QSA]
在我看来,它检查前面没有协议的有效URL,即
http://
https://
部分


在我的测试中,我没有发现它向web服务器发出任何
HEAD
请求。

谢谢William。根据您的回答,为什么上述两个条件都返回TRUE。你能提供一个适当的方法来实现它的例子吗?我认为你混淆了真与假。我确认这两个条件在Apache服务器上都会返回FALSE。我已经编辑了这个问题。以下两个条件都重定向到hello.php,这意味着这两个RewriteCond都是有效的,除了
^google$
既不是有效的/现有的url,也不是有效的/现有的路径。我不明白。。。两者中的任何一个都重定向到index.php。可能是因为
foo
。。。但你有一点,-U是根据协议反应的。我已经编辑了这个问题。你能看一下吗-你是根据冒号来反应的。。。更令人困惑的是:)有趣的是,我发现除了冒号之外,在检查
-U
条件时,当它在URL中找到
%
*
时,它还返回false。是的,它肯定不会发出任何
HEAD
请求。