【问题标题】:Yii2 and .htaccess redirect 301 from /index.php with or without querystring (/index.php?r=xxxxxx) to just / (root)Yii2 和 .htaccess 将 301 从 /index.php 重定向 301 有或没有查询字符串 (/index.php?r=xxxxxx) 到只是 / (root)
【发布时间】:2017-07-19 20:30:01
【问题描述】:

我正在使用 Yii2 和漂亮的 URL,它们运行良好。问题是所有丑陋的 URL 也都可用,并且 Bing 正在使用 index.php 索引一些页面,以及使用 querystring 索引其他一些页面。我该如何防止这种情况?如何从 /index.php 重定向到带有或不带有查询字符串 (/index.php?r=xxxxxx) 的 htaccess 中的 / (root)。

我在这里和网络上看到了很多解决方案,但没有一个对我有用。 非常感谢

【问题讨论】:

    标签: apache .htaccess yii2


    【解决方案1】:

    【讨论】:

    • 感谢您的回复。为了更好地理解,请尝试使用默认的 yii2 安装并启用漂亮的 Urls。您会注意到“example.com/about”按预期工作,但“example.com/index.php?r=about”也可用(虽然没有显示关于页面,但显示的是主页)。在本例中,我想禁用任何查询字符串 (404) 或将其重定向到“example.com/about”。那是我的问题(或 Bing 问题)
    猜你喜欢
    • 2010-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-26
    相关资源
    最近更新 更多