【问题标题】:301 redirect index.html to index.php and hide index.php from the url301 将 index.html 重定向到 index.php 并从 url 中隐藏 index.php
【发布时间】:2016-12-26 16:19:53
【问题描述】:

我最近将我的网站页面更改为 .php 在我有一个重写规则以将 example.com/index.html 显示为 example.com/

现在我想要相同但重定向到 index.php

我尝试了一些东西,但我以一个循环结束.. 正确的方法是什么? 所有这一切都是为了防止 google 将 index.php 作为一个新页面,而不是 index.html 的演变 我想用 htaccess 来做这一切,我已经用这种方式为其他每个页面做了这件事:

重定向 301 /old-url-name.html http://www.example.com/new-url-name.php

还有.. 有没有办法从它们各自的文件夹中隐藏所有 index.php?

【问题讨论】:

    标签: url-redirection


    【解决方案1】:

    要防止 Google 将这两个网址编入索引,您必须使用 canonical 元标记:

    <link rel="canonical" href="https://www.example.com/" />
    

    不需要从 index.php 重定向,只是不要在您网站的任何地方链接 index.php 页面。换句话说,替换这个:

    <a href="https://www.example.com/index.php">Home</a>
    

    用这个:

    <a href="https://www.example.com/">Home</a>
    

    【讨论】:

    • 但是我删除了我的旧 html,我读到正确的方法是使用 301 重定向。链接示例是一个很好的提示,谢谢
    猜你喜欢
    • 2010-10-27
    • 1970-01-01
    • 2010-11-20
    • 2014-01-14
    • 2015-07-05
    • 1970-01-01
    • 2014-09-27
    • 2020-07-07
    • 1970-01-01
    相关资源
    最近更新 更多