简体   繁体   中英

nginx - Serve Single URL with Absolute FIle Path

I have a website that's getting a ton of traffic to a single url.

https://www.awebsite.com/some/really/long/search-friendly/url/my-url.html

I want to serve this, and only this url statically with nginx. The static html file lives at /my/html-files/myfile.html, with the correct permissions.

I DO NOT want this url to be affected:

https://www.awebsite.com/some/really/long/search-friendly/url/some-other-url.html

I've tried...

location = /some/really/long/search-friendly/url/myfile.html {
    alias /my/html-files/myfile.html;
}

and...

location = /some/really/long/search-friendly/url/myfile.html {
    root /my/html-files/myfile.html;
}

and...

location = /some/really/long/search-friendly/url/myfile.html {
    root /my/html-files/;
}

I can't get anything to work. Please help! Thanks.

UPDATE:

Turns out this is working in Chrome and Opera.

location = /some/really/long/search-friendly/url/myfile.html {
    alias /my/html-files/myfile.html;
}

For whatever reason, in Firefox, I'm constantly redirected to https://www.awebsite.com/some/really/long/search-friendly/url/my-url.html/ . So Confused as to why this is happening only in FF, but, I'll take it for now.

Turns out this is working in Chrome and Opera.

location = /some/really/long/search-friendly/url/myfile.html {
    alias /my/html-files/myfile.html;
}

If it's not, see comments; it could be a browser caching problem.

Nginx documentation for alias

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