想要實現的效果是
abc.com/hello => abc.com/article.php?link=hello
abc.com/en/ = > abc.com/index.php?lang=en
abc.com/en/hello => abc.com/article.php?link=hello&lang=en
目前的寫法是
location / {
try_files $uri $uri/ =404;
if (!-e $request_filename){
rewrite ^/(.*)$ /article.php?link= last;
}
}
location /en/ {
rewrite index index.php?lang=en;
rewrite ^/en/(.*)$ /article.php?link=&lang=en last;
}
目前的問題是abc.com/hello是沒問題的,abc.com/en/hello也是沒問題的,abc.com/en/會被當成hello那樣解析出現錯誤
/en/ 也作為一個rewrite規則來做