Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to convert these rules from Apache rewrite to nginx:

RewriteRule ^([^/]+)/([^/]+)?$ api.php?version=$1&call=$2 [L]

I tried adding the following in the nginx config:

 rewrite ^([^/]+)/([^/]+)?$ api.php?version=$1&call=$2

but I only receive a 404 error when I visit my site.

I want my URL to look like:

 http://mysite/1.0/Something

How can I convert these rules to nginx?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Add a / to your rewrite-destination and set the last flag.

rewrite ^([^/]+)/([^/]+)?$ /api.php?version=$1&call=$2 last;
share|improve this answer
add comment

Here are two converters, but double check the conversion output as well

http://winginx.com/htaccess

http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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