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

Looking to convert the follow Apache rewrite rules over to Nginx. We are trying to get this to work on a subdirectory but can't seem to get the syntax down correctly.

RewriteRule ^([^//]+)/?(.{2})?/$ index.php?page=$1 [QSA,L]

RewriteRule ^([^//]+)/?(.*)?/index([0-9]*).ht(m?ml?)$ index.php?page=$1&rlVareables=$2&pg=$3 [QSA,L]

RewriteRule ^([^/][\w\-\_]+)(.+)-l?([0-9]+).ht(m|ml)$ index.php?page=$1&rlVareables=$2&listing_id=$3 [QSA,L]

RewriteRule ^((\w{2})/)?([\w-_]{3,})$ index.php?page=$3&lang=$2&account_request [QSA,L]

RewriteRule ^([^//]+)/?(^/*)?.ht(m?ml?)$ index.php?page=$1 [QSA,L]

RewriteRule ^([^//]+)/?(.*)?/?(.*)?(.ht(m?ml?)|/+)$ index.php?page=$1&rlVareables=$2 [QSA,L]
share|improve this question

1 Answer 1

up vote 0 down vote accepted
location /something {
  rewrite "^/([^//]+)/?(.{2})?/$" /index.php?page=$1 break;
  rewrite ^/([^//]+)/?(.*)?/index([0-9]*).ht(m?ml?)$ /index.php?page=$1&rlVareables=$2&pg=$3 break;
  rewrite ^/([^/][\w\-\_]+)(.+)-l?([0-9]+).ht(m|ml)$ /index.php?page=$1&rlVareables=$2&listing_id=$3 break;
  rewrite "^/((\w{2})/)?([\w-_]{3,})$" /index.php?page=$3&lang=$2&account_request break;
  rewrite ^/([^//]+)/?(^/*)?.ht(m?ml?)$ /index.php?page=$1 break;
  rewrite ^/([^//]+)/?(.*)?/?(.*)?(.ht(m?ml?)|/+)$ /index.php?page=$1&rlVareables=$2 break;
share|improve this answer

Your Answer


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.