当我浏览http://example.com/forum/1/page.PHP上的一个页面时,它可以正常工作,但有时候当我不小心输入example.com/forum/1(没有尾随斜线)时,它会不断加载,最终导致到错误页面ERR_CONNECTION_TIMED_OUT.地址栏显示已将其重定向到http://example.com:4000/forum/1/.
由于我没有打开4000端口,所以当我继续多次访问example.com/forum/1时,它将会被CSF触发一个块.我的问题是,我可以将所有指向实际文件夹example.com/forum/1(无拖尾斜杠)的请求重定向到404页面吗?我已经尝试添加一个重写规则,为每个请求附加一个斜杠,但这会破坏我的所有相对路径(请参阅我在post的问题).
所以我想知道的是,为什么我从http://example.com/forum/1重定向到http://example.com:4000/forum/1/?是否由HAproxy引起?
一些HAproxy配置:
frontend all 0.0.0.0:80 timeout client 1h # use apache2 as default webserver for incoming traffic default_backend apache2 backend apache2 balance roundrobin option forwardfor server apache2 myIpAddress:4000 weight 1 maxconn 1024 check # server must be contacted within 5 seconds timeout connect 5s # all headers must arrive within 3 seconds timeout http-request 3s # server must respond within 25 seconds. should equal client timeout timeout server 25s
这是我的重写规则:
RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l RewriteRule ^ - [L] RewriteCond %{REQUEST_URI} !^.*\.(jpg|css|js|gif|png)$[NC] RewriteCond %{REQUEST_FILENAME}.PHP -f RewriteRule !.*\.PHP$%{REQUEST_FILENAME}.PHP [QSA,L] RewriteCond %{THE_REQUEST} /index\.PHP [NC] RewriteRule ^([^\.]+)$$1.PHP [NC,L]