# Nginx rewrite to specific route

**URL:** <https://discourse.slimframework.com/t/nginx-rewrite-to-specific-route/1017>\
**Category:** Questions\
**Created:** [December 20, 2016, 9:35pm UTC](https://discourse.slimframework.com/t/nginx-rewrite-to-specific-route/1017 "2016-12-20T21:35:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![testforecho](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@testforecho](https://discourse.slimframework.com/u/testforecho)\
**Post date:** [December 20, 2016, 9:35pm UTC](https://discourse.slimframework.com/t/nginx-rewrite-to-specific-route/1017/1 "2016-12-20T21:35:08Z")

</div>

I am working on migrating a legacy API codebase to Slim. I would like to preserve backwards compatibility with the old routes by doing nginx rewrites of the old route names to the new Slim routes.

Is it possible to do a rewrite to a specific route? I have not been able to accomplish this. For example, if all of the new routes are prefixed with /api/, I would like to do something like the following in my nginx configuration file:

rewrite ^oldRouteName$ /api/newRouteName

When I try the above rewrite, my requests hit my Slim instance, but not the specific route that I want, although /api/newRouteName exists and handles direct requests properly. I always hit my Slim 404 Not Found handler with the above configuration.

Any ideas?
