fix(api): 修复空action参数处理并添加伪静态规则

修复当action参数为空时API根路径的错误处理
添加.htaccess伪静态规则以支持更友好的API URL
This commit is contained in:
2025-07-12 17:17:27 +08:00
parent 91cc01bd67
commit da631ff924
2 changed files with 8 additions and 2 deletions

View File

@@ -3,4 +3,10 @@ LimitRequestBody 524288000
# 错误处理
ErrorDocument 500 /error_pages/500.html
ErrorDocument 404 /error_pages/404.html
ErrorDocument 404 /error_pages/404.html
# API 伪静态规则
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api(/.*)?$ api.php?action=$1 [QSA,L]

View File

@@ -6,7 +6,7 @@ header('Content-Type: application/json');
$requestMethod = $_SERVER['REQUEST_METHOD'];
// API根路径处理 - 返回可用端点信息
if (!isset($_GET['action'])) {
if (!isset($_GET['action']) || $_GET['action'] === '') {
http_response_code(200);
echo json_encode([
'status' => 'success',