search

Home  >  Q&A  >  body text

nginx pseudo-static problem

How to configure nginx so that when www.x.cn/a is opened, www.x.cn/a.html is accessed

PHP中文网PHP中文网2864 days ago527

reply all(1)I'll reply

  • 某草草

    某草草2017-05-16 17:17:30

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    <code>server {

      index index.html index.php;

      location / {

        try_files $uri $uri/ $uri.html $uri.php?$query_string;

      }

      location ~ \.php$ {

        try_files $uri =404;

        # add fastcgi_pass line here, depending if you use socket or port

      }

    }</code>

    The core is the use of the try_files command, you can refer to the NGINX documentation

    reply
    0
  • Cancelreply