config all requests to one page nginx 1

config all requests to one page nginx

server {

    listen 80;
    listen [::]:80;
    server_name morioh.com;
    root /var/www/morioh.com;
    
    location / {
         try_files $uri $uri/ /index.html;
    }
}

Here is what the above code is Doing:
1. We’re telling Nginx to listen on port 80.
2. We’re telling Nginx to listen on port 80 for IPv6 connections.
3. We’re telling Nginx that the server name is morioh.com.
4. We’re telling Nginx that the root directory is /var/www/morioh.com.
5. We’re telling Nginx to try to serve the requested file, if it doesn’t exist, try to serve the requested file with a trailing slash, if that doesn’t work, serve the index.html file.

Now, we need to create the index.html file.

sudo nano /var/www/morioh.com/index.html

Similar Posts