2010-10-04 20 views
0

我有一个Godaddy的豪华Windows主机帐户,我试图用Web.Config设置URL重写。在GoDaddy上使用IIS的URL重写 - 为什么它不起作用?

,我读了GoDaddy的具有插件安装IIS URL重写,但他们自己也没有支持任何(在这里看到:http://help.godaddy.com/article/5443

我在web.config尝试一个简单的重写规则,但什么都没有发生:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rewriteMaps> 
       <rewriteMap name="StaticRedirects"> 
        <add key="test.php" value="/test" /> 
       </rewriteMap> 
      </rewriteMaps> 
     </rewrite> 
    </system.webServer> 
</configuration> 

当我访问test.php时,它不会被重写为/test并且不会引发任何错误。任何想法为什么?

最后,我想要做的主要改写是从rewrite.php?id=1/1

假设我可以重写所有工作,我需要使用什么匹配规则来完成这项工作?

在此先感谢!

回答

0

要重写http://mydom.com/1http://mydom.com/test.php?id=1 -

<rules> 
    <rule name="tw"> 
    <match url="([0-9]+)" /> 
    <action type="Rewrite" url="test.asp?id={R:1}" appendQueryString="false" /> 
    </rule> 
</rules> 

要重写http://mydom.com/test.php?id=1http://mydom.com/1

<rules> 
    <rule name="RedirectUserFriendlyURL1" stopProcessing="true"> 
    <match url="^test\.php$" /> 
    <conditions> 
     <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /> 
     <add input="{QUERY_STRING}" pattern="^id=([^=&amp;]+)$" /> 
    </conditions> 
    <action type="Redirect" url="{C:1}" appendQueryString="false" /> 
    </rule> 
    <rule name="RewriteUserFriendlyURL1" stopProcessing="true"> 
    <match url="^([^/]+)/?$" /> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="test.php?id={R:1}" /> 
    </rule> 
</rules> 

我生成这些使用UrlRewriter向导。如果你有IIS7提供您可以下载并安装由:

URL Rewrite (IIS.NET)

+0

伟大的作品,谢谢! – MarathonStudios 2010-10-06 01:49:09