Nginx重写-不工作
我有简单的nginx重写,我无法开始工作 我有这个网址: 我想重定向到: 我的nginx配置:Nginx重写-不工作,nginx,Nginx,我有简单的nginx重写,我无法开始工作 我有这个网址: 我想重定向到: 我的nginx配置: location / { index /index.php; rewrite ^/dk/$1/$2.html /$1/$2.html last; } 这里有什么想法是错误的吗?$1和$2用于捕获。您必须使用模式与组一起创建捕获 试试下面 location / { index /index.php; rewrite ^/([^/]+)/([^/]+).html$ /dk/$1
location / {
index /index.php;
rewrite ^/dk/$1/$2.html /$1/$2.html last;
}
这里有什么想法是错误的吗?
$1
和$2
用于捕获。您必须使用模式与组一起创建捕获
试试下面
location / {
index /index.php;
rewrite ^/([^/]+)/([^/]+).html$ /dk/$1/$2.html last;
}
或者你可以做下面的事情
location / {
index /index.php;
location /accessories/ {
alias <yourroot>/dk/accessories/;
}
}
位置/{
index/index.php;
位置/附件/{
别名/dk/附件/;
}
}
您的重写规则是否应该反过来<代码>最后重写^/([^/]+)/([^/]+).html$/dk/$1/$2.html代码>@abskmj,是的。谢谢!索引应始终为Index Index.php代码>