重定向根 URL - IIS 7 [英] Redirect root URL - IIS 7

查看:22
本文介绍了重定向根 URL - IIS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上安装了一些论坛,网址为 使用 301 重定向:

点击右侧面板上的Apply,你应该很高兴.

注意:如果您的 Redirect URL 与您的 Pattern 不匹配,您将陷入无限循环(您可以通过只需单击 Test 按钮即可编写您的 Pattern).

此模块的文档此处

I have some forums installed on my site at http://ironnoob.com/forums.

My website lives in c:IronNoob and my forums are installed in c:IronNoobforums

I want both "ironnoob.com" and "www.ironnoob.com" to do a server-side redirect to "ironnoob.comforums".

I'm using IIS 7 and I'm new to setting up this stuff so I don't even know what to google for. I know I can do a client-side redirect with HTML, but I understand that the server-side redirect is nicer. I've figured out how to install the HttpRedirect module for IIS, but if I set up a redirect in the root folder of my site to my forums folder, I get a circular redirect error when visiting ironnoob.com.

HTTP Redirect Settings:

  1. root directory selected in Connections pane of ISS
  2. Check "Redirect requests to this destination"
  3. destination = http://somesite.com/forums
  4. Check "redirect all requests to the exact location"
  5. Check "only redirect requests to content in this directory (not subdirectories)"
  6. Status code: Permanent (301)

Why is it redirecting subdirectories when I told it not to? What is the right way to do this?

解决方案

Instead of using the HTTP redirect module, you can use the URL rewrite one.

Run the inetmgr command and select your website root. Open the URL rewrite configuration:

Click on Add a rule on the right panel. Select a Blank rule in inbound rules:

From here you have to name your rule and select the Does not match the pattern option. You then have to set the Pattern (in this case, it means that a URL not starting with forums will trigger this rule):

The last step is to set up your redirect. You probably want to go with a 301 redirect as advised by Google:

Click Apply on the right panel and you should be good to go.

NOTE: If your Redirect URL doesn't match your Pattern you will be stuck in an infinite loop (you can test it by simply clicking the Test button will writing your Pattern).

Documentation for this module available here

这篇关于重定向根 URL - IIS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆