[英]301 Redirect for IIS
When I've used Apache, I used .htaccess to redirect a custom path to a certain page.当我使用 Apache 时,我使用 .htaccess 将自定义路径重定向到某个页面。
But my new site is hosted on a Windows server and I cant find any help on setting up redirects for old pages which have been deleted for new pages.但是我的新站点托管在 Windows 服务器上,我找不到任何帮助来为已为新页面删除的旧页面设置重定向。
Example.例子。 When people visit
当人们参观
[domain]/ValveMonitoring/valveleak.php
They should be forwarded to他们应该被转发到
[domain]/valve-monitoring/midas-meter.php
Can someone help?有人可以帮忙吗?
The rewrite is the way to do this as codechurn points out.正如 codechurn 指出的那样,重写是执行此操作的方法。 Here is an example of what you can stick in the web.config at the root of the site.
这是您可以在站点根目录下的 web.config 中粘贴的示例。 Its really quite simple:
它真的很简单:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="TestRewrite">
<!-- The match is a regex, hence the escaped '.' -->
<match url="someFile\.php" />
<action type="Redirect" redirectType="Permanent" url="PHPisSilly.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
You will have to make sure the rewrite module is installed.您必须确保安装了重写模块。 On Win10 go here to make sure:
在 Win10 上去这里确保:
Control Panel -> Programs -> Programs and Features -> Turn Windows features on or off -> Internet Information Services -> World Wide Web Services -> Common HTTP Features控制面板 -> 程序 -> 程序和功能 -> 打开或关闭 Windows 功能 -> Internet 信息服务 -> 万维网服务 -> 通用 HTTP 功能
And just enable all those options under "Common HTTP Features" and you should be good to go (except maybe Directory Browsing and WebDAV Publishing).只需启用“通用 HTTP 功能”下的所有这些选项,您就可以开始使用了(目录浏览和 WebDAV 发布除外)。 Press OK and close.
按确定并关闭。
The easiest way to do this in IIS7 and beyond is to install the URL Rewrite module.在 IIS7 及更高版本中执行此操作的最简单方法是安装 URL Rewrite 模块。 Please see the following for documentation: http://learn.iis.net/page.aspx/734/url-rewrite-module
请参阅以下文档: http ://learn.iis.net/page.aspx/734/url-rewrite-module
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.