Rai*_*aiN 2 linux configuration webserver nginx
我有这个 NGINX 配置:
root /var/www/web;
index index.php;
server_name domain.com;
access_log off;
error_log on;
location / {
rewrite ^/(.*)$ /index.php?tag=$1&page=1 last;
}
Run Code Online (Sandbox Code Playgroud)
现在,我想将“domain.com/index.php?tag=1§ion=2&type=3”之类的网址重定向到“domain.com/tag/section/type”
我该怎么做,我应该把代码放在哪里?请帮忙,
谢谢
我已经尝试过:
location / {
rewrite ^/index\.php?tag=(.*)§ion=(.*)&type=(.*)$ /$1/$2/$3 permanent;
rewrite ^/(.*)$ /index.php?tag=$1&page=1 last;
}
Run Code Online (Sandbox Code Playgroud)
但它没有用..
andrewrite指令location使用不包含查询字符串的规范化 URI。
要测试查询字符串,您需要使用语句和/或指令来查阅$request_uri或$args变量。ifmap
使用的优点$request_uri是它包含原始请求,有助于避免重定向循环。
如果您只需要执行一次重定向,则map解决方案可能会溢出。
尝试:
if ($request_uri ~ ^/index\.php\?tag=(.*)§ion=(.*)&type=(.*)$) {
return 301 /$1/$2/$3;
}
location / {
...
}
Run Code Online (Sandbox Code Playgroud)
请参阅此有关使用的注意事项if。
| 归档时间: |
|
| 查看次数: |
7647 次 |
| 最近记录: |