【问题标题】:htaccess - This webpage has a redirect loophtaccess - 这个网页有一个重定向循环
【发布时间】:2013-12-27 09:53:14
【问题描述】:

不像以前,现在在htaccess中应用了一个简单的url。

ErrorDocument 404 /404.php
Options +FollowSymlinks
RewriteEngine on

RewriteRule ^Customer-cat(.+)/(.+)$ /Customer-cat.php?Mcat_id=$1&customCat=$2 [L]

现在我无法访问该页面并重定向到 404 页面(损坏的页面)

This webpage has a redirect loop

当我删除 Options +FollowSymlinks 时,我会收到此消息

Forbidden

You don't have permission to access / on this server.

我进入 httpd.conf 发现 mod rewrite 没有注释。

LoadModule rewrite_module modules/mod_rewrite.so

是否应该启用其他模块?

谢谢。

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    您需要遵循符号链接,否则 mod_rewrite 根本不起作用。您还应该删除Multiviews。您拥有的规则是循环的,因为 mod_rewrite 将继续运行规则,直到 URI 停止更改,并且您的目标 Customer-cat.php 匹配相同规则的模式 ^Customer-cat(.+),因此它只会不断被应用。添加一些条件来防止这种情况:

    ErrorDocument 404 /404.php
    Options +FollowSymlinks -Multiviews
    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^Customer-cat(.+)/(.+)$ /Customer-cat.php?Mcat_id=$1&customCat=$2 [L]
    

    【讨论】:

      猜你喜欢
      • 2012-06-30
      • 1970-01-01
      • 2014-12-27
      • 2013-12-22
      • 2013-11-06
      • 2013-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多