A
A
AtomHQ2020-11-01 18:21:04
Nginx
AtomHQ, 2020-11-01 18:21:04

A simple Nginx Unit configuration for SPA. How to redirect all requests to index.html?

{
  "listeners": {
    "*:8300": {
      "pass": "routes"
    }
  },

  "routes": [
    {
      "match": { "uri": "/api/" },
      "action": { "pass": "applications/api" }
    },
    {
      "match": {"uri": ["*.css", "*.ico", "*.jpg", "*.js", "*.png", "*.html"] },
      "action": {"share": "/var/www/site.ru/dist/", "fallback": { "return": 404 }}
    },
    {
      "action": {

         /* ???????????????? */
        "pass": "/var/www/site.ru/dist/index.html"
      }
    }
  ],
  "applications": {
    "api": {
      "type": "php",
      "root": "/var/www/site.ru/api/",
      "script": "index.php"
    }
  }
}


how to redirect request like /catalog?category=33 to index.html?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question