【问题标题】:Redirect a Specific Page to another Page and Domain将特定页面重定向到另一个页面和域
【发布时间】:2019-12-12 03:56:30
【问题描述】:

我在服务器上安装了一个网站脚本并指向多个域。有时我需要将特定页面重定向到另一个站点,现在,我使用 Cloudflare 功能来重定向页面,但免费计划用户有限制。那么,我想知道如何使用 .htaccess、PHP 等重定向特定域上的特定页面?

例如,我在first.com 和second.com 上有内容/blabla,然后我想将页面first.com/blabla 重定向到third.com/target 但不在second.com/blabla 上,两个域具有相同的IP 和内容在同一个文件夹中。

谢谢

【问题讨论】:

    标签: javascript php .htaccess redirect


    【解决方案1】:

    在 php 中重定向:

    <?php header('Location: '. $newURL); ?>
    

    在 javascript 中重定向:

    <script>window.location.href = "newurlhere";</script>
    

    【讨论】:

      【解决方案2】:

      这应该适合你。

      RewriteEngine on
      
      
      RewriteCond %{HTTP_HOST} ^(www\.)?first\.com$ [NC]
      RewriteRule ^/?blabla http://third.com/something [L,R]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-04-20
        • 1970-01-01
        • 1970-01-01
        • 2011-12-21
        • 2010-12-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多