2024年04月01日 建站教程
nginx部署react刷新出现404应该如何解决,下面web建站小编给大家详细介绍一下!
解决404部署
server { listen 80; server_name https://www.xxx.com; location / { root xxx; index index.html index.htm; rewrite ^/(.*)/(.*\.js$) /$1/$2 break; rewrite ^/(.*)/(.*\.map$) /$1/$2 break; rewrite ^/(.*)/(.*\.css$) /$1/$2 break; rewrite ^/(.*)/(.*\.(png|jpg|gif)$) /$1/$2 break; rewrite ^/(.*)/(.*\.(ttf|woff|woff2|svg|otf|eot)$) /$1/$2 break; rewrite ^/(.*)/ /$1/index.html break; } } server { listen 443; server_name 54.222.208.17; ssl on; ssl_certificate /etc/nginx/your.pem; ssl_certificate_key /etc/nginx/your.key; ssl_session_timeout 5m; #charset koi8-r; #access_log logs/host.access.log main; location / { root xxx; index index.html index.htm; rewrite ^/(.*)/(.*\.js$) /$1/$2 break; rewrite ^/(.*)/(.*\.map$) /$1/$2 break; rewrite ^/(.*)/(.*\.css$) /$1/$2 break; rewrite ^/(.*)/(.*\.(png|jpg|gif)$) /$1/$2 break; rewrite ^/(.*)/(.*\.(ttf|woff|woff2|svg|otf|eot)$) /$1/$2 break; rewrite ^/(.*)/ /$1/index.html break; } }
本文链接:http://so.lmcjl.com/news/873/