You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP MVC项目Telegram机器人Webhook返回302 Found错误求助

Telegram Webhook返回302错误的排查求助

我有一个基于PHP的MVC站点,接收Webhook响应时,Telegram返回错误信息:Wrong response from the webhook: 302 Found。

  • 已通过https://api.telegram.org/botTOKEN/setwebhook?url=https://mysite-domain/webhook成功注册Webhook。
  • SSL证书采用Let's Encrypt。

getWebhookInfo()方法执行结果

[ok] => 1
[result] => Array
      (
                [url] => https://mysite-domain/webhook
                [has_custom_certificate] => 
                [pending_update_count] => 8
                [last_error_date] => 1658579570
                [last_error_message] => Wrong response from the webhook: 302 Found
                [max_connections] => 40
                [ip_address] => x.x.x.x
      )

我认为问题出在.htaccess配置上。根目录下的.htaccess(1)将请求重定向到/public文件夹,而/public下的.htaccess(2)将请求转发到index.php。特此求助,感谢所有提供帮助的人。

文件夹结构

- app
  ---controllers
  ---models
  ---views 
- config
- public
  ---files
  ---css, js
  ---index.php
  ---.htaccess (2)
- vendor
- composer.json
- .htaccess (1)

.htaccess (1)

AddDefaultCharset utf-8

RewriteEngine On
RewriteRule (.*) public/$1

.htaccess (2)

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule (.*) index.php?$1 [L,QSA]

php_flag session.use_trans_sid Off
php_flag session.use_only_cookie On
php_flag session.auto_start On

php_value session.gc_maxlifetime 604800
php_value session.cookie_lifetime 604800

Options -Indexes

内容的提问来源于stack exchange,提问作者Chingis Khuurak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 19:54:27