devin
1
I have tried tons of combinations without any luck:
I want to get this rule:
http://www.domain.com/uk/ → 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:
devin
2
Try this:
rewrite ^/([a-zA-Z]+)/$ /index.php?country=$1 break;
devin
3
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.
devin
4
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 / {
some-non-rewrite-rules-only-basic-config-rules
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:
devin
5
As usual, my fault
The problem was the “rule order”.
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php last;
break;
}
rewrite "^/({2})/?$" /index.php?country=$1 last;
The first rule stopped the second one from working.
Posted at Nginx Forum: