두 개의 URL이 동일한 파일로 연결됨

두 개의 URL이 동일한 파일로 연결됨

nginx를 사용하여 동일한 PHP 파일을 가리키려면 두 개의 URL이 필요합니다. 어떻게 해야 하나요?

예:

api.example.com/users => /var/www/public_html/index.php/users
example.com/api/users => /var/www/public_html/index.php/users

노력하고있어:

location ~ ^/api/(.*)$ {
   try_files $uri $uri/ /index.php?$1;
}

그러면 요청 URL에 '/api/'가 추가됩니다. 이를 어떻게 방지할 수 있나요?

관련 정보