简体   繁体   中英

Nginx rewrite rule to redirect from requested url to specific url

I'm trying to redirect from requested html file to specific location.

for example:

FROM

https://example.com/cars/description/ferrari-1-1532.html

to

https://example.com/car/catalog/ferrari.html

I tried this configuration

location /cars/description/*.html {
     rewrite ^(.*)$ https://examples.com/car/catalog/request_filename redirect;
}

But it is not working.

This location should redirect all requests to html files in /cars/description directory to this url https://examples.com/car/catalog/request_filename

location ~* /cars/description/(.+\.(html))$ {
     rewrite ^(.*)$ https://examples.com/car/catalog/request_filename redirect;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM