# homework18 **Repository Path**: SuWeiWei0627/homework18 ## Basic Information - **Project Name**: homework18 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-29 - **Last Updated**: 2026-05-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # homework18 HTTP 头实验 本目录包含题目要求的 PHP 页面。可放到 Nginx 的站点根目录,也可以在本目录临时运行 PHP 内置服务器: ```bash php -S 127.0.0.1:8000 ``` Nginx + PHP-FPM 示例配置如下,注意把 `root` 改成你的实际目录: ```nginx server { listen 80; server_name localhost; root /Users/suweiwei/Desktop/homework18; index index.php index.html; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } } ``` 然后访问: - `http://127.0.0.1:8000/set_cookie.php` - `http://127.0.0.1:8000/session_counter.php` - `http://127.0.0.1:8000/method_test.php` - `http://127.0.0.1:8000/redirect.php` - `http://127.0.0.1:8000/cache_demo.php` - `http://127.0.0.1:8000/ua.php` - `http://127.0.0.1:8000/statuscode.php?code=404` - `http://127.0.0.1:8000/down.php?type=inline` - `http://127.0.0.1:8000/down.php?type=attachment` 常用 curl 检测命令: ```bash curl -i http://127.0.0.1:8000/set_cookie.php curl -i -c cookies.txt -b cookies.txt http://127.0.0.1:8000/session_counter.php curl -i 'http://127.0.0.1:8000/method_test.php?name=tom' curl -i -X POST -d 'name=tom&age=18' http://127.0.0.1:8000/method_test.php curl -i -X PUT -d 'PUT body test' http://127.0.0.1:8000/method_test.php curl -i http://127.0.0.1:8000/redirect.php curl -i http://127.0.0.1:8000/cache_demo.php curl -i -A 'curl/8.0' http://127.0.0.1:8000/ua.php curl -i http://127.0.0.1:8000/statuscode.php?code=503 curl -i 'http://127.0.0.1:8000/down.php?type=attachment' ``` 注意:`redirect.php` 已设置 `Referrer-Policy: no-referrer`,用于观察如何避免重定向时泄露 Referer。