使用nginx
服务器。
当网址为sitename.com/test
并且有对test.php的调用
例如:
项目结构
public_html
|
+-somedir1
| |
| +-somefiles....
+-somdir2
|
+-login.php
+-info.php
+-something.php
......
当网址为sitename.com/login
时...致电login.php
,sitename.com/info
致电info.php
等。
server {
listen 80 default;
root /home/prod/frontend;
index index.php index.html index.htm;
charset utf-8;
server_name ui;
access_log /var/log/nginx/ui.access.log;
error_log /var/log/nginx/ui.error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\. {
deny all;
}
}
我也试试
location / {
try_files $uri.php $uri/ /index.php?$args;
}
location / {
index $uri.php
}