【问题标题】:Need to redirect a bad URL to a good URL in the same hosting which uses different domain需要将坏 URL 重定向到使用不同域的同一主机中的好 URL
【发布时间】:2016-05-01 16:53:57
【问题描述】:

问题很简单:

在更改客户端的当前托管之前,我有一个临时域名来启动网站(针对以前托管的各种问题)。

因此,该网站使用错误的 URL 存在了一段时间,例如: http://www.morphartsolution.com/tau2015/

这种情况持续了几个月,谷歌将错误的 URL 放在搜索结果中。现在该网站已上线: http://www.marchestau.com

我想删除对 morphartsolution.com/tau2015/ 的任何引用。为了自然地做到这一点,我想从 morphartsolution.com/tau2015/ 到 marchestau.com 进行 .htaccess 重定向,但无法正常工作。

morphartsolution 和 marchestau 域都在同一个主机(服务器)中,morphartsolution 是主域名,marchestau 是在 tau2015/ 文件夹中工作的附加域。

有什么线索可以为此在 .htaccess 中添加什么魔法?

谢谢!

【问题讨论】:

  • 显示你到目前为止所做的尝试
  • 我投票决定将此问题作为题外话结束,因为这是一个关于网站管理的问题——而不是编程问题——因此可能属于Webmasters Stack Exchange

标签: php apache .htaccess redirect mod-rewrite


【解决方案1】:

您需要来自

的永久重定向

将以下行添加到您的 htaccess 中:

Redirect 301 /tau2015 http://www.marchestau.com

如果上述重定向失败,请尝试 mod-rewrite :

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?oldddomain.com$
RewriteRule ^tau2015/(.*)$ http://www.marchestau.com/$1 [NE,L,R=301]

【讨论】:

    【解决方案2】:

    我认为您想将 http://www.morphartsolution.com/tau2015/ 的每个页面原样重定向到 http://www.marchestau.com/,例如,http://www.morphartsolution.com/tau2015/example.phphttp://www.marchestau.com/example.php

    所以把下面的代码放到htaccess@tau2015文件夹里

    RewriteEngine On
    RewriteRule ^(.*)$ http://www.marchestau.com/ [R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-06
      • 2016-03-01
      • 2023-03-13
      • 1970-01-01
      • 2015-03-15
      • 1970-01-01
      相关资源
      最近更新 更多