Another rewrite question

I have tried tons of combinations without any luck:

I want to get this rule: -> index.php?country=uk

From Apache:
RewriteRule ^({2,}/)$ index.php?country=$1
RewriteRule ^({2,})$ index.php?country=$1
RewriteRule ^({2}/)index.php$ index.php?country=$1

I tried in location /:
rewrite “^({2}/)$” index.php?country=$1 break;
rewrite “^/({2}/)$” index.php?country=$1 break;

What I’m missing?

Posted at Nginx Forum:,1026,1026#msg-1026

Try this:

rewrite ^/([a-zA-Z]+)/$ /index.php?country=$1 break;

The forum ate some of your rules, here is the right one (I think):

rewrite ^/([a-z]{2})/?$ /index.php?country=$1 break;

Basically, do no use quotes.

I already tried this one.

I’m using quotes due to the brackets {}, if I don’t use them, nginx
fails to read the config, as {} are used by nginx config.

I have:

location / {
if (!-e $request_filename) {
go to index.php
rewrite ^/()/?$ /index.php?country=$1 break;

And it still doenst works.

Thnx for your help.

Posted at Nginx Forum:,1026,1044#msg-1044

As usual, my fault :wink:

The problem was the “rule order”.

            if (!-e $request_filename) {
                    rewrite ^(.*)$ /index.php last;

           rewrite "^/({2})/?$" /index.php?country=$1 last;

The first rule stopped the second one from working.

Posted at Nginx Forum:,1026,1045#msg-1045

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs