第二步、配置 Nginx 反向代理
使用如下 Nginx 配置(其中,webadmin.php 是 admin.php(由于安全原因 admin.php 被重命名))
server {
listen 80;
server_name videos.k4nz.com;
root /srv/maccms10/;
index index.php index.html index.htm;
location /asdfasdfasfdsafsfsafsadf {
rewrite ^(.*)$ /index.php?s=$1 last;
}
location / {
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^/webadmin.php(.*)$ /webadmin.php?s=$1 last;
rewrite ^/api.php(.*)$ /api.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
通过如下方法进行伪静态配置:
1)管理后台 / 系统 / URL地址配置 / 路由伪静态设置 / 伪静态状态:开启
2)使用如下 Nginx 配置:
server {
listen 80;
server_name videos.k4nz.com;
root /srv/maccms10/;
index index.php index.html index.htm;
location /asdfasdfasfdsafsfsafsadf {
rewrite ^(.*)$ /index.php?s=$1 last;
}
location / {
if (!-e $request_filename) {
# 管理后台后台
rewrite ^/admin/(.*)$ /webadmin.php?s=/admin/$1 last;
# 对外接口
rewrite ^/provide/(.*)$ /api.php?s=/provide/$1 last;
# 页面显示
rewrite ^/index.php/(.*)$ /index.php?s=$1 last; # 修复在页面中的硬编码
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}