Home  >  Q&A  >  body text

nginx accesses the specified directory based on the information in the URL

For example, my current URL (beautified URL) is
/1/test/test
Then nginx does the processing, and the access directory is /home/data/segmentfault/1/web
After nginx Processing, the actual URL is
/1/web/index.php?test/test

Beautified URL
/2/test/test
The access directory is /home/data/segmentfault/2/web
The actual URL is
/2/web/index.php? test/test

Just select different folders based on the version number, and then the pathinfo mode will still take effect. The framework code is Yii2.

How to set the jump rules of nginx?
Or is there any relevant information? How to describe such an internal jump? Are there any proper nouns to describe it?

淡淡烟草味淡淡烟草味2713 days ago485

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 17:21:55

    Use regular matching in location. When root sets the directory, read the regular matching content to assemble the path.
    Related nginx terms: location, regular, set directive, map directive, root directive, alias directive.

    reply
    0
  • 为情所困

    为情所困2017-05-16 17:21:55

    You don’t need to do any extra settings at all with this access method. . .

    server {
            listen 80;
            server_name segmentfault.com;
            include enable-php.conf;
            location ~ \.php$ {
            include fastcgi.conf;
            }
            root /home/data/segmentfault;
            index index.html index.php;
    }

    reply
    0
  • Cancelreply