Requirements: Access to/var/data/www through example.com, but EXAMPLE.COM/PA access is/var/data/phpmyadmin, that is, protection phpMyAdmin is not exposed to the WWW directory.
One, method one: (not recommended)
Introduction: This is a popular way of Rewrite on the Internet.
BUG: A simple PHP program can cope with a complicated program "No input file specified"
Server {Listen the; server_name example.com; Root/var/data/www; Index index.html index.php; Location/PA {alias/var/data/phpMyAdmin; Index index.html index.php; } Location~/pa/.+\.php$ {rewrite/pa/(. +\.php)/$1 Break; Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param Script_filename/var/data/phpmyadmin/$fastcgi _script_name; Include Fastcgi_params; } Location~. +\.php.*$ {Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root/$fastcgi _script_name; Fastcgi_param script_filename $request _filename; Include Fastcgi_params; }}
Two, method two: (recommended)
Introduction: Perfect realization, no side effects.
Features: A variable called "$valid _fastcgi_script_name" is used
Server {Listen the; server_name example.com; Root/var/data/www; Index index.html index.php; Location/PA {alias/var/data/phpMyAdmin; Index index.html index.php; } Location~/pa/.+\.php.*$ { if($fastcgi _script_name ~/pa/(. +\.php.*)$) { Set$valid _fastcgi_script_name $1; } Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param Script_filename/var/data/phpmyadmin/$valid _fastcgi_script_name; Include Fastcgi_params; } Location~. +\.php.*$ {Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root/$fastcgi _script_name; Fastcgi_param script_filename $request _filename; Include Fastcgi_params; }}
Two, method three:
Summary: The creative approach seen on zhigang.net, which is one station plus two server fields, is then implemented in a reverse fashion.
Specific: The method is creative, a little bit troublesome.
Nginx directory Aliases (alias) Support PHP configuration