【问题标题】:Confused about 301 redirect, need suggestions对301重定向感到困惑,需要建议
【发布时间】:2013-09-02 06:44:47
【问题描述】:

我想 301 将 .net 网站重定向到我的 .com 网站,但不确定重定向内页的正确方法。这是我想做的:

  1. 将.net站点的主页重定向到.com站点的内页——oldsite.net到newsite.com/ranking-page.php

  2. 将此.net站点的部分内页重定向到.com站点的相关内页,如下所示:

oldsite.net/party-poker/ 到 newsite.com/party-poker.php

oldsite.net/us-poker/ 到 newsite.com/us-poker-sites.php

还有 2-3 个内页 url 被重定向到 newsite.com 的相关内页。

  1. 将 oldsite.net 的所有其他内页重定向到 newsite.com/ranking-page.php

让我知道是否可以通过 htaccess 做这样的事情。如果不可能,我只想将整个 oldsite.net 站点及其所有内页 301 发送到 newsite.com/ranking-page.php。再次,让我知道如何使用 htaccess 做到这一点。

我尝试了 2 种不同的方法,但没有奏效。 #1 我使用此代码将整个 oldsite.net 网站重定向到 newsite.com/ranking-page.php,如下所示:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.newsite.com/ranking-page.php$1 [R=301,L]

但这会将内部页面重定向到类似的 url 结构,如 oldsite.net/strategy/ 到 newsite.com/strategy/,而我在 newsite.com 上没有这样的页面/url 结构。尝试了其他一些方法,但似乎没有任何效果......:/

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    您需要为每个案例创建一个重定向:

    RewriteEngine on
    RewriteRule ^$ http://www.newsite.com/ranking-page.php [L,R=301]
    RewriteRule ^party-poker/$ http://newsite.com/party-poker.php [L,R=301]
    RewriteRule ^us-poker/$ http://newsite.com/us-poker-sites.php [L,R=301]
    # the other 2-3 inner page urls
    
    # finally, everything to ranking page
    RewriteRule ^ http://www.newsite.com/ranking-page.php [L,R=301]
    

    【讨论】:

    • 你先生,是个摇滚明星!非常感谢老板 - 你是最棒的! :)
    • 嘿,还有 1 个问题。如果我在其他网站上使用 oldsite.net 上的内容,会不会有问题?我的意思是它的所有页面现在都被重定向到newsite.com/ranking-page.php,所以如果我在我的某个新网站上使用旧网站上的内容也没关系...?
    • @user2738855 不明白为什么这会是一个问题,除非您创建了包含主机名的链接(例如&lt;a href="http://oldsite.com/some/content.html"&gt;content&lt;/a&gt;)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-15
    • 1970-01-01
    • 2022-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多