我需要将根路径单独重定向到特定的URL和其他路径的其他路径。
例如:
http://localhost/example should be redirected to http://localhost/example/index.php?route=common/home
http://localhost/example/welcome-to-this should be redirected to http://localhost/example/index.php?route=welcome-to-this
我试过这种方式
location /example {
rewrite ^ /example/index.php?_route_=common/home last;
}
location /example/(.*)$ {
rewrite ^/(.+)$ /example/index.php?_route_=$1 last;
}
答案 0 :(得分:0)
试试这个:
location = /example {
return 301 $scheme://$host/example/index.php?route=common/home;
}
location ~ ^/example/(.*)$ {
return 301 $scheme://$host/example/index.php?route=$1;
}