当匹配到地址
http://xxx/sites/app/avatar/0F0993200F910338F0EE638EFDFA1779
要求请求
http://xxx/sites/app/index.php?m=user&c=index&a=avatar&user_id=0F0993200F910338F0EE638EFDFA1779
下面的写法好像不行
location / {
rewrite ^sites/app/avatar/(.*)$ /sites/app/index.php?m=user&c=index&a=avatar&user_id=$1 last;
try_files $uri $uri/ =404;
}
1
yangg 2018-07-19 16:16:05 +08:00
rewrite ^/sites....$
少了个 / |
2
mafeifan OP location / {
rewrite ^sites/app/avatar/(.*)$ /sites/app/index.php?m=user&c=index&a=avatar&user_id=$1 last; try_files $uri $uri/ =404; } # pass PHP scripts to FastCGI server location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; } 还是报 404,求助啊 |
3
mafeifan OP rewrite ^/sites/app/avatar/(.*)$ /sites/app/index.php?m=user&c=index&a=avatar&user_id=$1 last;
|
4
wu67 2018-07-19 16:40:47 +08:00
\/sites\/app\/avatar\/(.*)$
这样? |
5
imdong 2018-07-19 16:48:54 +08:00
不需要 location 字段也可以噻
server { listen 80; root "/web"; # 重写规则 rewrite ^/sites/app/avatar/(.*)$ /sites/app/index.php?m=user&c=index&a=avatar&user_id=$1 last; location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; ... } } |