I'm trying to redirect mywebsite.com/some-directory to a different directory other than the root of mywebsite.com. I used the following configuration :
server {
server_name mywebsite.com www.mywebsite.com;
listen 80;
root /path/to/the/root/directory/of/mywebsite;
index index.php index.html index.htm get.html ;
ssl on;
listen 443 ssl;
ssl_certificate my_ssl.crt;
ssl_certificate_key my_key.key;
location /some-directory {
root /path/to/directory;
}
}
The configuration loads the html file but doesn't load the assets in the same directory.
I found a similar question (or probably the exact one), but the issue was different. I was able to fix that on my own.
I also tried using the alias as suggested in the answer above; but in vain.
My /path/to/directory/ has some-directory within it, and nginx serves the index.html file just fine. The problem occurs when the HTML file tries to access the files (or folders) within /path/to/directory/some-directory. They all return 404 Not Found.
What could I be doing wrong?
some-directoryitself. Say, the images are insome-directory/assets/images, css insome-directory/assets/css/, js insome-directory/assets/jsand others insome-directory/assetsas well. – shine Feb 29 '16 at 18:37http://mywebsite.com/some-directory/assets/css/filename.cssor something else? – Richard Smith Feb 29 '16 at 19:20nginx-error.logcontain a detailed error message for the 404? – Richard Smith Feb 29 '16 at 19:27[error] 6499#0: *xx open() "/path/to/some/directory/assets/images/image.png" failed (2: No such file or directory), client: xxx.xxx.xxx.xxx, server: mywebsite.com, request: "GET /some-directory/assets/images/image.png HTTP/1.1", host: "mywebsite.com", referrer: "https://mywebsite.com/some-directory/"– shine Feb 29 '16 at 19:33