【问题标题】:Rewriting url and htaccess (localhost)重写 url 和 htaccess (localhost)
【发布时间】:2018-10-18 09:10:45
【问题描述】:

我正在学习一个教程来重写我的帖子的网址(例如:articles/presentation-et-demonstration-des-jeux-videos-a-venir-pour-l-annee-2018- 516 而不是 articles.php?billet=516presentation-et-demonstration-des-jeux-videos-a-venir-pour-l-annee-2018),但我收到了本地错误语句,带有以下消息:

此页面无法正常工作

localhost 重定向太多次。

尝试删除 cookie..

ERR_TOO_MANY_REDIRECTS

在我这边,php.ini 和 httpd.conf 设置为可以正常使用。 此外,我已经删除了导航器中的 cookie。

这是我在我的 .htaccess 中使用的代码,我把它放在好的根目录中:

RewriteEngine On
RewriteRule articles/([a-zA-Z0-9\-]+)-([0-9]+) articles.php?id=$2 [L]

有人可以帮我解决这个问题吗?

提前谢谢你,

【问题讨论】:

  • 去禁用 MultiViews ...
  • 您能告诉我应该如何禁用 MultiViews 吗?

标签: php .htaccess url-rewriting localhost


【解决方案1】:

这不是 .htaccess 错误或 .htaccess 写错

这个错误

此页面无法正常工作

localhost 重定向太多次。

可能是因为网站总是将 javascript 中的 header('location: url');window.location.href 读取到相同的direction/url

如果您在文件 index.php 中使用 header('location: index.php'),这意味着每次您读取/打开 index.php 时,您都会被 定向index.php,当你再次阅读/打开时,它会让你再次被重定向。所以服务器通过这个error来阻止这种情况。

注意

如果你使用header('location: url'),请确保你正确使用它,因为.htaccess文件通过article.php检查所有内容重定向如果您的代码中有任何重定向功能

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-26
    • 2021-01-30
    • 1970-01-01
    • 2015-07-28
    • 2013-06-23
    • 1970-01-01
    相关资源
    最近更新 更多