nginx mod rewrite 有问题。非常感谢帮助。我在这个问题上花了好几个小时
重写 URL 时出现问题。
我想要重写 bangots.eu/?subtopic=highscores bangots.eu/?subtopic=houses
得到这个
bangots.eu/highscores bangots.eu/houses
我有这个代码
rewrite ^/([^/]*).html$ /?subtopic=$1 last;
有 2 点错误。1. 我不需要 .html 扩展名 2. 此重写规则将我从 bangots.eu/highscores.html 转到 bangots.eu/?subtopic=highscores。我想将其反转。谢谢您的帮助!
这是我的 /etc/nginx/sites-available/default 的一部分
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name bangots.eu;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ index.php$is_args$args =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
rewrite ^/([^/]*).html$ /?subtopic=$1 last;
}