My angular application is running on nginx server. When I type http://**.8.100.248:30749
it show nginx is running. (Showing default index.html). But my application is present in html
folder having folder name test
. So my application present in “html —> test—> index.html”;;
So when I type http://**.8.100.248:30749/test/index.html
my application run on browser, but when I route from one page to another and reload
my page it gives me 404
.
Nginx gives me 404 when I reload my angular routed page. So I changed the nginx config but still not success
location / {
root /usr/share/nginx/html;
index index.html index.htm;
expires -1;
add_header Pragma "no-cache";
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
try_files $uri$args $uri$args/ $uri $uri/ /test/index.html =404;
}
any update
在您的配置中将root
更改为/usr/share/nginx/html/test
应该可以解决您的问题。
In your config file add the following:
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
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.