我们使用Wordpress移动插件将Wordpress站点从blog.ourdomain.com迁移到www.ourdomain.com/blog,我们无法获得301个重定向工作。这是我们的整个过程..。
..。在这一点上,新的网站运行正常..。
下面是我们需要的一个例子:
旧URL http://blog.ourdomain.com/2017/03/orientation-packages-for-new-employees/
需要301重定向到:http://www.ourdomain.com/blog/2017/03/orientation-packages-for-new-employees/
也许子目录是困扰我们的部分,但我们根本没有成功地使用htaccess,甚至没有重定向到错误的URL。唯一做任何更改的是使用IIS进行重定向,这只会重定向:http://blog.ourdomain.com/2017/03/orientation-packages-for-new-employees/ to:http://www.ourdomain.com/blog/
请帮帮忙。我们还应该试试什么?我们做错什么了?
发布于 2017-03-28 16:02:45
谢谢大家的建议。最终起作用的是在web.config文件中使用特定的重定向。我们这里最大的问题是不理解htaccess文件只供Apache使用。我们有Windows和IIS7,它使用web.config文件。下面是我们添加的一些例子。请理解,这对我们的工作,因为我们的Wordpress安装使用的URL格式。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect - Category - Paging">
<match url="^category/([_0-9a-z-] )/page/([0-9] )/" />
<action type="Redirect" url="http://www.ourdomain.com/blog/category/{R:1}/page/{R:2}" redirectType="Permanent" />
</rule>
<rule name="Redirect - Category">
<match url="^category/([_0-9a-z-] )/" />
<action type="Redirect" url="http://www.ourdomain.com/blog/category/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Redirect - Author">
<match url="^author/([_0-9a-z-] )/" />
<action type="Redirect" url="http://www.ourdomain.com/blog/author/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Redirect - Individual Blog">
<match url="^([0-9] )/([0-9] )/([_0-9a-z-] )/" />
<action type="Redirect" url="http://www.ourdomain.com/blog/{R:1}/{R:2}/{R:3}" redirectType="Permanent" />
</rule>
<rule name="Redirect - Month Archive">
<match url="^([0-9] )/([0-9] )/" />
<action type="Redirect" url="http://www.ourdomain.com/blog/{R:1}/{R:2}" redirectType="Permanent" />
</rule>
<rule name="Redirect - About Us">
<match url="^about-us/" />
<action type="Redirect" url="http://www.ourdomain.com/blog/about-us" redirectType="Permanent" />
</rule>
<rule name="Redirect - Privacy">
<match url="^privacy/" />
<action type="Redirect" url="http://www.ourdomain.com/blog/privacy" redirectType="Permanent" />
</rule>
<rule name="Redirect - Home Page - Paging">
<match url="^page/([0-9] )/" />
<action type="Redirect" url="http://www.ourdomain.com/blog/page/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Redirect - Home Page">
<match url="^" />
<action type="Redirect" url="http://www.ourdomain.com/blog" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
https://stackoverflow.com/questions/42957271
复制相似问题