<route url="/V1/api/orders/:id" method="GET">
        <service class="Lovat\Api\Api\OrdersRepositoryInterface"
            <resource ref="anonymous"/>

i create an API, and everything works well, but i i would like to change url API now URL looks like that http://localhost/rest/all/V1/api/orders/2

how can i edit url to http://localhost/api/V1/orders/2

1 Answer 1


I think the easiest way will be to create a rewrite rule and let it do the job. Refer to this lijnk for creating a rule in Apache - https://httpd.apache.org/docs/trunk/rewrite/remapping.html

If using Nginx then you can also search for it about how to rewrite the url. This way you don't have to change much of the code.

  • how is it possible to implement this with code? Jul 23, 2020 at 12:14
  • Your server is running on nginx or apache? Accordingly the answer will vary
    – Arif Ahmad
    Jul 23, 2020 at 12:17
  • I am writing a plugin that will install on Magento and I need to solve this problem with code if possible Jul 23, 2020 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.