fix(api): 修复空action参数处理并添加伪静态规则
修复当action参数为空时API根路径的错误处理 添加.htaccess伪静态规则以支持更友好的API URL
This commit is contained in:
@@ -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]
|
||||
2
api.php
2
api.php
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user