0

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.

4
  • As you've noted, the alias option is a working solution. Have you cleared the FF browser's cache? Commented Oct 11, 2018 at 8:21
  • I thought shift-R was a hard refresh in FF. Am I wrong about this? Commented Oct 11, 2018 at 18:32
  • 1
    I think you mean Ctrl-R (which is the same as F5) and does not override the cache. You would need to use Ctrl-Shift-R (or Ctrl-F5) to override the cache. Commented Oct 11, 2018 at 19:45
  • Because it was a redirect that was cached, I had to go into Preferences and manually clear the cache, restart FF and it started working as expected. Commented Oct 12, 2018 at 14:39

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.