2
在nginx位置重写前缀url
我的nginx配置文件是这样的: server { listen 80; listen 443 ssl; server_name XXX.com; error_log /log/nginx/xxx.com_error.log; access_log /log/nginx/xxx.com_access.log main; root /data/www/; index index.php index.html index.htm; location ~ \.php$ { add_header X-Frame-Options SAMEORIGIN; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 我们需要配置nginx以满足以下要求: 1,如果URL 没有前缀“ /api/mobile/index.php”,并且请求的端口是80,则将其重定向到https 2,如果URL 具有前缀“ /api/mobile/index.php”,请继续 因此,我在配置文件中添加了内容: location ~ ^(?!/api/mobile/index\.php).*$ { if …