URL 重写:“http://myServer/”到“http://myServer/sites/site1”。?
我正在尝试使用 IIS7 上的 URL 重写模块来执行以下重定向/重写(不知道什么对我的情况更好):
我希望此 URL "http://myServer/" 为重定向/重写到“http://myServer/sites/site1”。
提前非常感谢,任何帮助将不胜感激:)
YASH23
I am trying to use URL Rewrite module on IIS7 to do the following redirection/rewrite (don't know what's better for my case):
I want this URL "http://myServer/" to be redirected/rewritten to "http://myServer/sites/site1".
Thanks alot in advance, any help would be greatly appreciated :)
YASH23
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这是您要做的唯一重定向,并且您还不熟悉重写模块,那么它会比必要的更加令人困惑。我建议创建一个默认站点,当您转到根 URL (http://myServer/) 时加载,并在名为 default.asp 的文件中包含以下代码:
这将执行永久重定向。如果您愿意执行临时重定向(以便搜索引擎稍后检查),请执行 302 重定向:
或者,如果您仍想使用 IIS URL 重写,则正则表达式应仅检查空字符串:
If this is the only redirect you'll be doing, the rewrite module is going to be more confusing than necessary if you're not already familiar with it. I recommend creating a Default site that loads when you go to the root URL (http://myServer/), with the following code in a file named default.asp:
That will do a permanent redirect. If you'd rather do a temporary redirect (so search engines will check there later), do a 302 redirect:
Or, if you'd like to still use IIS URL Rewrite, the regex should just check for an empty string: