1

我已经在整个网站和网络上进行了搜索,但我仍然无法做到这一点。我有很多这样的 URL:http://archives.cancunandrivieramaya.com/archives/cancun.cgi/md/read/id/XXXX我想重定向到主页http://www.cancunandrivieramaya.com/。子域不再存在。如何编写 mod-rewrite 以将末尾带有通配符的子域重定向到主页?这是100个不起作用的之一:(

RewriteCond %{HTTP_HOST} !^www\.cancunandrivieramaya\.com [NC]
RewriteCond %{HTTP_HOST} ^archives\.cancunandrivieramaya\.com([a-z0-9]+)\
RewriteRule (.*) http://www.cancunandrivieramaya.com/[L,QSA]

任何帮助将非常感激。

4

1 回答 1

0

我知道了!感谢 Altaf Khatri 的这篇文章http://www.altafkhatri.com/Technical/Configure/How-to-publish-or-host-subdomain-on-winhostcom/Solution-resolution我能够一步一步地跟随他在 WinHost 上设置子域的步骤说明,然后我将此规则添加到 web.config 文件中:

<rule name="archive redirect" enabled="true" stopProcessing="true">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^www\.archives\.cancunandrivieramaya\.com$" />
          </conditions>
          <action type="Redirect" url="http://www.cancunandrivieramaya.com/" />
        </rule>

        <rule name="archives 2" enabled="true" stopProcessing="true">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^(www\.)?archives\.cancunandrivieramaya\.com$" />
            <add input="{PATH_INFO}" pattern="^/archives/($|/)" negate="true" />
          </conditions>
           <action type="Redirect" url="http://www.cancunandrivieramaya.com/" />
        </rule>

完美运行!

于 2012-11-09T02:18:33.387 回答