【问题标题】:How to redirect one page to another and then all remaining pages to a new site如何将一个页面重定向到另一个页面,然后将所有剩余页面重定向到新站点
【发布时间】:2021-01-13 16:06:33
【问题描述】:

我需要实现 2 个重定向。

我想将example.com/subdir 重定向到 example1.com/subdir 然后我想将 example.com/ 上剩余的所有内容重定向到 example2.com/index.html

我尝试了以下方法,但没有找到我的解决方案:

redirect 301 /subdir https://example1.com/subdir
redirect 301 / https://example2.com/index.html

最终发生的一切都是重定向到https://example2.com/index.html

谢谢!

附加

我需要https://example.com/subdir 重定向到https://outlook.office365.com/owa/calendar/

然后,https://example.com 上的所有内容/其他任何内容都需要重定向到 example1.com 上的新站点

换句话说,example.com 上的所有内容都需要重定向到 example1.com/index.html 处的新压缩页面,但 example.com/subdir 需要转到 Outlook/office 365。

【问题讨论】:

    标签: apache .htaccess redirect mod-rewrite friendly-url


    【解决方案1】:

    您能否尝试以下,用所示示例编写。请确保在测试您的 URL 之前清除您的浏览器缓存。

    RewriteEngine ON
    RewriteCond %{HTTP_HOST} ^(?:www\.)example\.com [NC]
    RewriteRule ^(subdir)/?$ https://outlook.office365.com/owa/calendar [R=301,NE,L]
    
    RewriteCond %{HTTP_HOST} ^(?:www\.)example\.com [NC]
    RewriteRule ^ https://example1.com/your_single_page.html [R=301,NE,L]
    

    【讨论】:

    • "owa/calendar" 是 Microsoft Outlook 和 Office 365 站点的一部分。所以第一个重定向需要继续转到outlook.office365.com/owa/calendar,而剩下的所有内容都需要转到example1.com上新建和压缩的单页
    • @H.Ferrence,好的,我现在已经编辑了我的规则,请您尝试一下,如果对您有帮助,请告诉我?
    • 再次感谢您的所有帮助@RavinderSingh13!我非常感谢你和我一起度过的时光。但是最新的没有用。我需要继续做其他事情,所以我会用元重定向来解决这个问题(是的,我知道这是穷人的解决方案并且不友好)但我还有其他更紧迫的事情要做,所以你也要做.最好的问候...我要退出了。
    • @H.Ferrence,太棒了,很高兴它为你工作,不用为自己后悔,干杯和快乐学习伙伴干杯:)
    猜你喜欢
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    • 2014-08-10
    • 1970-01-01
    • 2019-03-31
    • 2023-02-02
    • 2019-11-21
    相关资源
    最近更新 更多