简体   繁体   中英

Rewrite nginx url specific location url with PHP

I'm trying to rewrite a location to https.

However I only want to do this at this specific location: http://test.org/forums/dfjk34dkk25cm369aa135cs56v34/

I only want the php files in that directory to be redirected to https.

My current attempt hasn't worked out. What have I done wrong?

location ~ /forums/dfjk34dkk25cm369aa135cs56v34\.php(/|$) {

    return 301 https://$host$request_uri;

}

This did the trick.

location ~ ^/forums/dfjk34dkk25cm369aa135cs56v34/.*php(/|$) {
  return 301 https://$host$request_uri;
}

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