在Windows Server 2008中的IIS 7上使用wordpress。在header.php文件中,我有一个硬编码链接
<a href="www.gohere.com?querystring=value">Link</a>
在页面加载后,链接自动呈现为
<a href="www.gohere.com/?querystring=value">Link</a>
如果只放入“www.gohere.com?querystring=value”,斜杠也会添加到URL的地址栏中。哪个可以,但在我的PHP代码中,我无法读取查询字符串的值。
读取qs的代码
$getThis = get_query_var('querystring');
if(!empty($getThis)){
...DO WORK BUT DOESN'T GET HERE
}
web.config的重写部分,因为这会进行一些读/写操作。没有像我在IIS上的htaccess
<rewrite>
<rules>
<rule name="WordPress Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false" />
<action type="None" />
</rule>
<rule name="WordPress Rule 2" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
<action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
</rule>
<rule name="WordPress Rule 3" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
<action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
</rule>
<rule name="WordPress Rule 4" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
</conditions>
<action type="None" />
</rule>
<rule name="WordPress Rule 5" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
<action type="Rewrite" url="{R:2}" />
</rule>
<rule name="WordPress Rule 6" stopProcessing="true">
<match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
<action type="Rewrite" url="{R:2}" />
</rule>
<rule name="WordPress Rule 7" stopProcessing="true">
<match url="." ignoreCase="false" />
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
答案 0 :(得分:0)
想通了我使用了错误的php代码来获取querystring的值。看起来这很好用。
$getThis = $_GET['querystring'];