我想重写网址
https://www.beecow.info/product/whosaler-san-pham-shop-dang-590-34-390-k-p345954
要 https://www.beecow.info/whosaler-san-pham-shop-dang-590-34-390-k-p345954
我想拆开/产品/这里是我的nginx配置
server {
listen 80;
server_name beecow.info;
return 301 https://www.beecow.info$request_uri;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.beecow.info localhost;
root /var/www/html/;
# Load configuration files for the default server block.
#include /etc/nginx/default.d/*.conf;
if ($http_x_forwarded_proto != "https") {
rewrite ^(.*)$ https://$server_name$1 permanent;
}
location ~* ^/product/(.*){
rewrite ^/product/(.*)$ /$1 last;
}
location / {
try_files $uri$args $uri$args/ /index.html;
}
但它不起作用。网址不再改变。
答案 0 :(得分:0)
您的重写不会改变它:
location ~* ^/product/(.*){
rewrite ^/product/(.*)$ /$1 last;
}
这样的事情将完成这项工作(未经测试):
location ~ /product/(.*)$ {
rewrite ^ /$1?$args permanent;
}