【发布时间】:2015-07-10 19:40:16
【问题描述】:
我在 IIS 中有一个重写规则,它应该将没有“www”的入站 URL 重写为“www”。重写规则实际上是重写 URL 以包含“www”,但它会将访问者定向到 /index.php,而不是将他们发送到他们试图访问的链接。
如果您想知道 php 扩展,我在 Windows 上使用 Joomla。我的重写规则写在 web.config 文件中。目前我的非 www 到 www 规则是第三条规则,我猜这可能是问题所在。前两个重写规则是 SEF 的 Joomla 默认规则。有谁知道将它移到第一条规则是否可以解决问题?
<rewrite>
<rules>
<rule name="Joomla! Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{QUERY_STRING}" pattern="base64_encode[^(]*\([^)]*\)" ignoreCase="false" />
<add input="{QUERY_STRING}" pattern="(>|%3C)([^s]*s)+cript.*(<|%3E)" />
<add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
<add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
</conditions>
<action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
</rule>
<rule name="Joomla! Rule 2" enabled="true">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^/index.php" ignoreCase="true" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
【问题讨论】:
标签: mod-rewrite joomla url-rewriting iis-7 web-config