feat: 添加.htaccess文件并简化index.php逻辑

添加.htaccess文件实现URL重写规则,将所有请求重定向到index.php
修改index.php逻辑,忽略请求路径直接返回固定JSON响应
This commit is contained in:
2025-11-25 17:26:11 +08:00
parent 620e7ce21c
commit 71e0d3ed7e
2 changed files with 18 additions and 2 deletions
+16
View File
@@ -0,0 +1,16 @@
# 启用URL重写引擎
RewriteEngine On
# 基础目录设置
RewriteBase /
# 如果请求的是一个存在的文件或目录,则不进行重写
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 所有请求都重定向到index.php
RewriteRule ^(.*)$ index.php [L]
# 确保查询字符串被保留
RewriteCond %{QUERY_STRING} .+
RewriteRule ^(.*)$ index.php?$0 [L,QSA]
+2 -2
View File
@@ -11,10 +11,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
}
// 定义文件路径
$urlFilePath = 'url.txt';
$authFilePath = 'auth.json';
// 读取并返回auth.json文件内容
// 忽略请求路径和查询参数,直接返回auth.json文件内容
// 无论访问路径是什么,都返回相同的固定JSON响应
if (file_exists($authFilePath)) {
// 读取JSON文件内容
$jsonContent = file_get_contents($authFilePath);