将特定urlredirect到不同的目录

我正尝试将mywebsite.com/some-directoryredirect到除mywebsite.com根之外的其他目录。 我使用了以下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; } } 

该configuration加载html文件,但不加载相同目录中的资产。

我发现了一个类似的问题 (或者可能是确切的问题),但问题是不同的。 我能够自己解决这个问题。

我也尝试使用上面的答案build议的别名; 但徒劳无益。

我的/path/to/directory/some-directorynginx服务的index.html文件就好了。 当HTML文件尝试访问/path/to/directory/some-directory的文件(或文件夹)时,会发生此问题。 他们都返回404未find。

我可能做错了什么?

我发现这个问题的重复,但它是在StackOverflow而不是ServerFault。

https://stackoverflow.com/questions/21628056/virtual-directory-counterpart-in-nginx

要将mywebsite.com/some-directoryredirect到不同于您网站根目录的目录,您可以使用下面的代码。

 root /path/to/the/root/directory/of/mywebsite; index index.php index.html index.htm get.html; location /some-directory/ { alias /path/to/some-directory/; index index.php; try_files $uri $uri/ /index.php?$args; } 

也读这个线程有关类似的问题。