从帖子表单获取无限循环。不确定这是否是一个htaccess问题

时间:2012-04-22 06:04:23

标签: php .htaccess

提交$ _POST ['form']时,如果空闲时间超过8或9分钟,我将收到超时错误;它总是在变化。这是错误的屏幕截图:

enter image description here

这是我在错误日志中得到的:

[Sat Apr 21 20:15:00 2012] [error] [client .......] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

它不能是我的脚本。这是一个非常标准的形式。此外,我在共享主机上的所有6个站点上收到此错误。这是我的.htaccess文件...

    Options +FollowSymLinks
    RewriteEngine On

    Options -Multiviews
    RewriteBase /

    RewriteRule ^([a-zA-Z0-9-]+/?)$ $1.php

    #edit forum question -- questions.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^edit/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+) edit.php?question_num=$1&question=$2 [NC]

    #edit forum question id -- questions.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^edit/([a-zA-Z0-9-]+) edit.php?question_num=$1 [NC]

    #usernames -- index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z0-9-]+) index.php?post=$1 [NC]

问题是在任何帖子表格上的网站范围。如果您等待提交时间过长,则会发生此超时错误。

我不认为这是php.ini的问题。我已经完成了所有内容:

register_globals = off
allow_url_fopen = off

expose_php = Off
max_input_time = 18000
max_execution_time = 18000

;extension_dir = ./
upload_tmp_dir = ./tmp

;precision = 12

session.cache_expire = 10080
session.cookie_lifetime = 200000
session.gc_maxlifetime = 10000

memory_limit = 100M
post_max_size = 100M
file_uploads = On
upload_max_filesize = 192M

签出.htaccess文件后,你能看到导致这种情况的原因吗?或者,它是完全不同的东西?我还应该注意到我正在使用cookie而没有会话数据。

1 个答案:

答案 0 :(得分:2)

你的htaccess需要一个L标志,否则它会无限循环 -

# Important L flag! 
RewriteRule ^([a-zA-Z0-9-]+/?)$ $1.php [L]

#edit forum question -- questions.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^edit/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+) edit.php?question_num=$1&question=$2 [NC,L]

#edit forum question id -- questions.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Important $ dollar sign next line - otherwise it matches above rule
RewriteRule ^edit/([a-zA-Z0-9-]+)$ edit.php?question_num=$1 [NC,L]

#usernames -- index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-]+) index.php?post=$1 [NC,L]

没有L它会重写规则并在重写后重新循环(再次重写)。