2

如果在文件夹下,我需要设置规则以将用户从一个子域推送到另一个子域。我需要搬家

  • teststore.domain.edu/admin*
  • devstore.domain.edu/admin*
  • anysubdomain.domain.edu/admin*

  • store.admin.domain.edu/admin

这行得通!

但我需要重写任何内容

  • store.admin.domain.edu

  • store.admin.domain.edu/admin

但这并没有,实际上除了

  • store.admin.domain.edu/media*
  • store.admin.domain.edu/js*
  • store.admin.domain.edu/skin*
  • store.admin.domain.edu/api*
  • store.admin.domain.edu/admin/oauth_authorize*
  • store.admin.domain.edu/index.php/admin*

需要将重定向写入

  • store.admin.domain.edu/admin*

我几乎拥有它,但 store.admin.domain.edu 通过以下规则重写为 devstore.domain.edu,因为它没有被捕获。我不能在下面的规则中添加任何内容,它是生成的。

<!-- RULES TO PUSH ADMIN TO SUBDOMAIN -->
<rule name="admin" stopProcessing="true">
  <match url="(.*)"  ignoreCase="true" />
  <conditions logicalGrouping="MatchAll">
    <add input="{HTTP_HOST}" pattern="store.admin.domain.edu" negate="true" />
    <add input="{URL}" pattern="^(.*?)/admin(.*?)" />
  </conditions>
  <action type="Redirect" url="http://store.admin.domain.edu/admin" appendQueryString="false" redirectType="Permanent" />
</rule>
<rule name="admin_rooted" stopProcessing="true">
  <match url="(.*)"  ignoreCase="true" />
  <conditions logicalGrouping="MatchAll">
    <add input="{HTTP_HOST}" pattern="store.admin.domain.edu" />
    <add input="{URL}" pattern="^/(api|oauth_authorize|media|skin|js)" negate="true" />
    <add input="{URL}" pattern="^admin*" negate="true" />
    <add input="{REQUEST_URI}" pattern="^index.php/admin/*" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
  </conditions>
  <action type="Redirect" url="http://store.admin.domain.edu/admin" appendQueryString="false" redirectType="Permanent" />
</rule>
<!-- END OF RULES TO PUSH ADMIN TO SUBDOMAIN -->



<!-- rules that are generated -->
<rule name="default_store">
    <match url="(.*)" ignoreCase="true" />
    <conditions>
      <add input="{SERVER_NAME}" pattern="^devstore\.domain\.edu*" />
    </conditions>
    <serverVariables>
      <set name="HTTP_X_MAGE_RUN_CODE" value="base" replace="true" />
      <set name="HTTP_X_MAGE_RUN_TYPE" value="website" replace="true" />
    </serverVariables>
    <action type="None" />
</rule>
<rule name="general_rewrite">
    <match url="(.*)" />
    <action type="Rewrite" url="index.php" />
    <conditions>
        <add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" /> 
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
</rule>
4

1 回答 1

1

我改变了你的两条规则,使它们更简单:

<rule name="admin" stopProcessing="true">
  <match url="^admin" ignoreCase="true" />
  <conditions logicalGrouping="MatchAll">
    <add input="{HTTP_HOST}" pattern="^store.admin.domain.edu$" negate="true" />
  </conditions>
  <action type="Redirect" url="http://store.admin.domain.edu/admin" appendQueryString="false" redirectType="Permanent" />
</rule>
<rule name="admin_rooted" stopProcessing="true">
  <match url="^(api|oauth_authorize|media|skin|js|admin|index.php/admin/)" ignoreCase="true" negate="true" />
  <conditions logicalGrouping="MatchAll">
    <add input="{HTTP_HOST}" pattern="^store.admin.domain.edu$" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
  </conditions>
  <action type="Redirect" url="http://store.admin.domain.edu/admin" appendQueryString="false" redirectType="Permanent" />
</rule>

第一条规则会将任何admin以.store.admin.domain.eduhttp://store.admin.domain.edu/admin

第二个将重定向任何不以以下事件开头的url:apioauth_authorizemedia或或skinjsadminindex.php/admin/指向主机store.admin.domain.edu而不是文件或目录的路径http://store.admin.domain.edu/admin

于 2013-08-10T22:49:02.920 回答