文件夹中文件的Nginx重写规则不工作 大家晚上好,如果你们是我的朋友,可能是清晨。
我的问题看似微不足道,但经过几个小时的测试、研究和修改,我似乎无法让这个简单的nginx重写功能正常工作 有几个重写,我们需要,有些将有多个参数,但我甚至不能得到这个简单的1个参数的当前网址改变在所有的理想 当前:website.com/public/viewpost.php?id=post title 需要:website.com/public/post/post title 有人能指出我做错了什么吗,我很困惑/很累 为了在启动之前进行测试,我们只是在服务器上使用了一个简单的端口。这是那一部分文件夹中文件的Nginx重写规则不工作 大家晚上好,如果你们是我的朋友,可能是清晨。,nginx,url-rewriting,Nginx,Url Rewriting,我的问题看似微不足道,但经过几个小时的测试、研究和修改,我似乎无法让这个简单的nginx重写功能正常工作 有几个重写,我们需要,有些将有多个参数,但我甚至不能得到这个简单的1个参数的当前网址改变在所有的理想 当前:website.com/public/viewpost.php?id=post title 需要:website.com/public/post/post title 有人能指出我做错了什么吗,我很困惑/很累 为了在启动之前进行测试,我们只是在服务器上使用了一个简单的端口。这是那一部分
# Listen on port 7004 for test
server {
listen 7004;
server_name localhost;
root /usr/share/nginx/html/paa;
index index.php home.php index.html index.htm /public/index.php;
location ~* /uploads/.*\.php$ {
if ($request_uri ~* (^\/|\.jpg|\.png|\.gif)$ ) {
break;
}
return 444;
}
location ~ \.php$ {
try_files $uri @rewrite =404;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location @rewrite {
rewrite ^/viewpost.php$ /post/$arg_id? permanent;
}
}
我尝试过无数次尝试,比如上面的@rewrite和simpler:
location / {
rewrite ^/post/(.*)$ /viewpost.php?id=$1 last;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
我似乎什么也做不到,我尝试过改变位置,尝试过多种规则
请告诉我我做错了什么
暂停facepalm此问题似乎属于Stack Exchange网络中的另一个站点,因为它与编程无关。也许吧。好的,谢谢你,我很快就会搬迁。有点不确定,因为设计的其他方面都是php。再次感谢。