首页 > 解决方案 > URL Rewrite web.config 在域和页面之间添加假文件夹

问题描述

只是一个简单的问题。我有一个域website.com,这个页面有以国家代码命名的特定页面。

我已经在我的 web.config 文件上创建了规则,并使用以下 URl 重写:

 <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
    <match url= "^([^/]+)/?$"/>          
      <conditions logicalGrouping="MatchAll">
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
     <action type="Rewrite" url="ContactUs.php?lang={R:1}" />
  </rule>

页面是在 PHP 中生成的,名为lang的变量用于显示选择的页面并存在于 URL 中。

我想在我的域和页面之间添加“联系人/” 。

我有以下规则:

<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
   <match url="contact([^/]+)/?$"/>
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
    <action type="Rewrite" url="ContactUs.php?lang={R:1}"/>
 </rule>

哪位大神可以解释一下我有什么不明白的,谢谢

标签: azureiisweb-config

解决方案


您的正则表达式略有错误。

^contact\/([a-z]+)\/?$

假设您所有的国家/地区代码都只是字母,那应该可以满足您的需要。


推荐阅读