我正在开发PHP CMS,目前正在实现静态文件缓存。缓存背后的想法是,所有页面都被编译为html,然后仅由apache或nginx提供服务。问题是,如果它不是GET请求,它仍然应该重写为PHP CMS,而不是直接服务。这是我当前的htaccess配置,我剥离了HTTPS重定向。
<IfModule mod_rewrite.c>
RewriteEngine On
# If the requested filename exists, simply serve it, but only if it is a GET request
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_METHOD} =GET
RewriteRule ^ - [L]
# Rewrite all other queries to the front controller.
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
但是,一旦我发送POST请求,它就会失败,并显示错误500。apache错误日志显示以下消息:
AH00124: 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., referer: http://jinya.local/contact
AH00121: r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /index.php, referer: http://jinya.local/contact
AH00122: redirected from r->uri = /contact, referer: http://jinya.local/contact
有人可以帮我弄清楚问题是什么吗?
答案 0 :(得分:1)
您的最后一条规则创建了一个无限的重写循环。
解决方法:不要在基本索引上应用规则
RewriteCond %{REQUEST_URI} !/index\.php$ [NC]
RewriteRule ^ %{ENV:BASE}/index.php [L]