首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >301用新URL重定向Wordpress

问301用新URL重定向Wordpress
EN

Stack Overflow用户
提问于 2017-03-22 16:16:17
回答 1查看 140关注 0票数 1

我们使用Wordpress移动插件将Wordpress站点从blog.ourdomain.com迁移到www.ourdomain.com/blog,我们无法获得301个重定向工作。这是我们的整个过程..。

  1. 将wordpress站点的文件文件夹复制为“blog.ourdomain.com- copy”
  2. 使用Wordpress Move插件将网址从blog.ourdomain.com更改为www.ourdomain.com/blog。
  3. 使用IIS,创建“blog”作为ourdomain.com下的虚拟目录,指向现有的“blog.ourdomain.com”文件夹。

..。在这一点上,新的网站运行正常..。

  1. 使用IIS,将blog.ourdomain.com请求指向“blog.ourdomain.com-Copy”,这样我们就可以在不影响活动站点的情况下处理htaccess和web.config文件夹。
  2. 我们在htaccess文件中尝试了几个不同的301组合,但是似乎没有什么效果。我们还尝试使用IIS进行重定向,但无法让IIS使用动态URL并将其重定向到正确的页面。

下面是我们需要的一个例子:

旧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/

请帮帮忙。我们还应该试试什么?我们做错什么了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-28 16:02:45

谢谢大家的建议。最终起作用的是在web.config文件中使用特定的重定向。我们这里最大的问题是不理解htaccess文件只供Apache使用。我们有Windows和IIS7,它使用web.config文件。下面是我们添加的一些例子。请理解,这对我们的工作,因为我们的Wordpress安装使用的URL格式。

​

代码语言:javascript
复制
<?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>

​

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42957271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档