简体   繁体   English

nginx-提供具有绝对文件路径的单个URL

[英]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 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. 我想提供此服务,并且仅使用nginx静态地提供此网址。 The static html file lives at /my/html-files/myfile.html, with the correct permissions. 静态html文件位于/my/html-files/myfile.html中,具有正确的权限。

I DO NOT want this url to be affected: 我不希望此网址受到影响:

https://www.awebsite.com/some/really/long/search-friendly/url/some-other-url.html 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. 原来,这在Chrome和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/ . 无论出于何种原因,在Firefox中,我都会不断重定向到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. 对于为什么仅在FF中发生这种情况感到很困惑,但是,我现在就来看它。

Turns out this is working in Chrome and Opera. 原来,这在Chrome和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 Nginx alias文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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