【问题标题】:mod_rewrite ERR_TOO_MANY_REDIRECTSmod_rewrite ERR_TOO_MANY_REDIRECTS
【发布时间】:2017-07-20 13:47:17
【问题描述】:

我在 apache2 中遇到了 mod_rewrite 的问题,我启用了 mod_rewrite 但没有加载我收到以下消息:ERR_TOO_MANY_REDIRECTS

.htaccess:

RewriteEngine on
RewriteRule ^(\w+)$ index.php?page=$1 [L,NC,QSA]

RewriteRule ^(\w+)+\/$ index.php?page=$1 [L,NC,QSA]

RewriteCond %{HTTP_HOST} !^$

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteCond %{HTTPS}s ^on(s)|

RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

IDK 出了什么问题。

【问题讨论】:

  • 请分享 apache.conf 以及您使用的 Apache 版本。谢谢。检查这些链接:serverfault.com/questions/595458/…serverfault.com/questions/698711/…stackoverflow.com/questions/36266626/…
  • 错误信息显示Apache在你的重定向之间陷入了无限循环,所以请检查前面的链接并检查你的重定向链。
  • 试过但没有运气,我的 apache.conf:pastebin.com/RaxWt8MG
  • RewriteEngine on RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} !^www\。 [NC] RewriteRule ^/(.*) http1://www.%{HTTP_HOST}%/$1 [R=301] RewriteCond "%{REQUEST_URI}" "!=/index.php" RewriteRule "^(.*) " "/index.php?page=$1" [L,PT]
  • 非常感谢,现在可以使用了!

标签: php .htaccess redirect mod-rewrite apache2


【解决方案1】:

使 .htacess 更轻松、更干净。

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule ^/(.*) http1://www.%{HTTP_HOST}%/$1 [R=301] 
RewriteCond "%{REQUEST_URI}" "!=/index.php" RewriteRule "^(.*)" "/index.php?page=$1" [L,PT]

作为主要步骤,它的解决方案无需 SSL 即可工作。

【讨论】:

    猜你喜欢
    • 2016-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-11
    • 2019-03-09
    • 2020-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多