我搜遍了这个网站和网站,但我仍然无法做到这一点。我有很多这样的网址: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]
非常感谢任何帮助。
答案 0 :(得分: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>
完美无缺!