网址从旧域重写为新域 [英] url rewrite from old to new domain
问题描述
大家好,我需要一个URL重写规则(IIS或Apache),该规则会将每个请求从旧域重写到新域.
请注意,它还必须重写子域甚至查询字符串,例如下面的内容;
Hi guys, i need a url rewrite rule (IIS or Apache) that will rewrite each request from old domain to new domain.
Please note that it has to rewrite also subdomains and even query string, example bellow;
products.olddomain.com > products.newdomain.com<br />
www.olddomain.com/default.aspx?test=1 > www.newdomain.com/default.aspx?test=1
不仅如此,它甚至还必须保留协议,因此,如果有这样的请求;
https://olddomain.com it should be https://newdomain.com
而且,我不想看到一个子域的示例,等等...我有数百个子域,它们是通用的,因此整个规则应该是动态的,并且能够接受所有类型的链接,并且在任何形式,都应简单地"从一个域切换到另一个域,并保持链接结构.
还有一件事,这应该是永久重定向
预先谢谢您.
and not only that, it even has to keep protocol, so if there was request like this;
https://olddomain.com it should be https://newdomain.com
and please, i don''t want to see examples for one subdomain, etc... i have hundrests of subdomains, which are generic, so this whole rule should be dynamic, and be able to accept all kind of links, and in any kind of form, and should "simply" switch from one domain to other, keeping link structure.
one more thing, this should be a permanent redirect
thank you in advance
推荐答案
第一个网站包含10个重写URL的技巧. #8是保留协议.它还将帮助您保留查询字符串(我仅在IIS 6.0中完成过此操作)很抱歉询问以前的IIS版本,之后我看到标记被标记为IIS7.
http://blogs.iis.net/ruslany/archive/2009/04/08/10-url-rewriting-tips-and-tricks.aspx [ http://www.iis.net/download/URLRewrite [ http://mvolo.com/blogs/serverside/pages/Redirect-requests-to-您的应用程序-HttpRedirection-module.aspx [ ^ ]
希望对您有帮助,并祝您好运!
The first website contains 10 tips for rewriting urls. #8 is to perserve the protocol. It also will help you with perserving the query strings(which I''ve only done in IIS 6.0) Sorry about asking which version of IIS earlier I saw the tag was marked IIS 7 afterwards.
http://blogs.iis.net/ruslany/archive/2009/04/08/10-url-rewriting-tips-and-tricks.aspx[^]
This is just the direct link to IIS 7 redirect module that appears in the above article.
http://www.iis.net/download/URLRewrite[^]
This is a persons blog on how to use the IIS 7 redirect module, which I have never personal used.
http://mvolo.com/blogs/serverside/pages/Redirect-requests-to-your-application-with-the-HttpRedirection-module.aspx[^]
I hope this helps and best of luck!
这篇关于网址从旧域重写为新域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!