我尝试重定向一个 URL,但什么也没发生。:( 源 URL 示例如下:
http://example.com/download.php?shortURL=MJdcqV
其中 是MJdcqV
可变参数,其他所有参数均为常量。我需要重定向如下:
http://example.com/views/download.php?shortURL=MJdcqV
我尝试用多种方式重写,但找不到正确的方法:
location /download.php {
rewrite ^/download.php$ /views/download.php redirect;
rewrite ^/download.php$ /views/download.php break;
rewrite ^/download.php$ /views/download.php last;
}
请给我一些建议或指出正确的方法。谢谢
答案1
尝试
location = /download.php {
rewrite ^ /views/download.php$is_args$args last;
}