Reputation: 725
I have simple nginx rewrite I can't get to work.
I have this url:
https://example.com/accessories/3427-tote-bag-grey-212345050033.html
I want to redirect to:
https://example.com/dk/accessories/3427-tote-bag-grey-212345050033.html
My nginx config:
location / {
index /index.php;
rewrite ^/dk/$1/$2.html /$1/$2.html last;
}
any idea want is wrong here?
Upvotes: 0
Views: 1454
Reputation: 146490
$1
and $2
are used for captures. You have to use pattern to with groups to create captures
Try below
location / {
index /index.php;
rewrite ^/([^/]+)/([^/]+).html$ /dk/$1/$2.html last;
}
Or you can do something like below
location / {
index /index.php;
location /accessories/ {
alias <yourroot>/dk/accessories/;
}
}
Upvotes: 1