🔧 Apache配置诊断

📋 Apache模块检查

⚠️ apache_get_modules() 函数不可用

📄 .htaccess文件检查

✅ .htaccess 存在

✓ RewriteEngine On 已设置

查看 .htaccess 内容
RewriteEngine On

# Authorization Header 支持 - 修复Token认证问题
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [E=HTTP_AUTHORIZATION:%1]

# 安全设置 - 禁止访问敏感文件
<FilesMatch "\.(env|log|ini|conf)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# 禁止直接访问配置目录
RewriteRule ^(config|database)/ - [F,L]

# API路由 - 将API请求路由到api目录
RewriteCond %{REQUEST_URI} ^/api/
RewriteRule ^api/(.*)$ api/$1 [L]

# 首页访问规则 - 访问根目录时显示index.php(如果存在)
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ index.php [L]

# 静态资源访问规则 - 直接访问public目录下的静态资源
RewriteCond %{REQUEST_URI} ^/public/
RewriteRule ^public/(.*)$ public/$1 [L]

# 登录页面特殊处理 - 确保/login能正确路由
RewriteCond %{REQUEST_URI} ^/login$
RewriteRule ^login$ public/index.php [L]

# 注册页面特殊处理
RewriteCond %{REQUEST_URI} ^/register$
RewriteRule ^register$ public/index.php [L]

# 其他认证相关页面
RewriteCond %{REQUEST_URI} ^/auth/
RewriteRule ^auth/(.*)$ public/index.php [L]

# 默认路由规则 - 其他请求重定向到public目录
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_URI} !^/api/
RewriteRule ^(.*)$ public/index.php [L]

# 缓存设置
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>

# Gzip压缩
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/json
</IfModule>

✅ public/.htaccess 存在

✓ RewriteEngine On 已设置

查看 public/.htaccess 内容
RewriteEngine On

# 处理前端路由
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

# 安全设置
<Files "*.php">
    Order Allow,Deny
    Allow from all
</Files>

# 禁止访问敏感文件
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|sql|conf)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# 设置缓存
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/ico "access plus 1 month"
    ExpiresByType image/icon "access plus 1 month"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
</IfModule>

# 启用Gzip压缩
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
</IfModule> 

🌍 服务器环境

SERVER_SOFTWARE: nginx/1.24.0

DOCUMENT_ROOT: /www/wwwroot/cn.qjbdsoft.com

REQUEST_URI: /debug-apache-config.php

SCRIPT_NAME: /debug-apache-config.php

SCRIPT_FILENAME: /www/wwwroot/cn.qjbdsoft.com/debug-apache-config.php

HTTP_HOST: cn.qjbdsoft.com

SERVER_NAME: cn.qjbdsoft.com

SERVER_PORT: 443

🔄 URL重写测试

当前页面URL: /debug-apache-config.php

⚙️ PHP配置

session.auto_start:

session.save_path: 默认

error_reporting: 32759

display_errors:

log_errors:

error_log: 默认

📁 目录权限检查

✅ . (权限: 0755, 可读, 可写)

✅ public (权限: 0755, 可读, 可写)

✅ app (权限: 0755, 可读, 可写)

✅ app/controllers (权限: 0755, 可读, 可写)

✅ app/views (权限: 0755, 可读, 可写)

✅ app/views/auth (权限: 0755, 可读, 可写)

🧪 手动路由测试

测试路径: /login

处理后的路径: 'login'

✅ 匹配登录路由

测试路径: login

处理后的路径: 'login'

✅ 匹配登录路由

测试路径: auth/login

处理后的路径: 'auth/login'

✅ 匹配登录路由