配置好nginx 和代码后
设置伪静态
location / {
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
#地址作为将参数rewrite到index.php上。
rewrite ^/(.*)$ /index.php?s=$1;
#若是子目录则使用下面这句,将subdir改成目录名称即可。
#rewrite ^/subdir/(.*)$ /subdir/index.php?s=$1;
}
}
location /api/ {
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
#若是子目录则使用下面这句,将subdir改成目录名称即可。
rewrite ^/api/(.*)$ /api.php?s=$1;
}
}
关闭防止跨站攻击 open_basedir
本文介绍了如何配置Nginx以实现伪静态,针对/api路径进行特别处理,并讲解了如何关闭open_basedir防止跨站攻击。重点在于前后端路由管理和安全性优化。
1573

被折叠的 条评论
为什么被折叠?



