nginx,重写url不起作用
我的重写URL不工作,这里是带有重写的nginx配置的一部分。谢谢你的建议nginx,重写url不起作用,url,nginx,rewrite,Url,Nginx,Rewrite,我的重写URL不工作,这里是带有重写的nginx配置的一部分。谢谢你的建议 location / { try_files $uri $uri/ @mylocation; } location @mylocation { rewrite ^index.php?p=/profile(.*)$ /profile/ redirect; rewrite ^.*$ /index.php last; } 请求永远不会到达@mylocation,因为我假设i
location / {
try_files $uri $uri/ @mylocation;
}
location @mylocation {
rewrite ^index.php?p=/profile(.*)$ /profile/ redirect;
rewrite ^.*$ /index.php last;
}
请求永远不会到达
@mylocation
,因为我假设index.php存在
试试这样的
location / {
try_files $uri $uri/ /index.php;
}
location /index.php {
if ($args ~* "^p=/profile.*") {
rewrite ^ /profile/? redirect;
}
}
“不工作”是什么意思?顺便说一句,第一次重写是错误的。无法在“重写”中匹配查询参数。