我如何更改网址中的参数
例如https://example.com/r.php?12345
到https://example.com/12345
?
nginx conf文件:
server {
listen 80;
server_name example.com;
rewrite_log on;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/example.com;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
以及添加块的位置 在conf文件里面?
答案 0 :(得分:0)
如果URI未映射到本地文件,则try_files
的最后一个元素是默认操作。所以用所需的重写替换你的404错误。尝试:
location / {
try_files $uri $uri/ /r.php?$uri;
}
有关详细信息,请参阅this document。