发布时间:2019-12-19 09:12:56 作者:佚名 阅读:(315)
最近朋友在搭建服务器的时候建议使用的lnmp的,在搭建好之后问lnmp伪静态的设置方法,接下来吾爱编程为大家介绍一下lnmp伪静态设置方法的设置方法,有需要的小伙伴可以参考一下:
我们在使用lnmp vhost add添加好网站之后,会在目录/usr/local/nginx/conf/vhost下面生成一个对应的配置文件,这里我的是www.itbiancheng.com.conf,添加不同的域名会生成不同的配置文件,这样可以方便的管理每个网站,避免多个网站都放在一个文件里面不好管理。
server { listen 80; server_name www.itbiancheng.com ; index index.html index.htm index.php default.html default.htm default.php; root /data/www/www.itbiancheng.com; include rewrite/other.conf; include enable-php-pathinfo.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ /.well-known { allow all; } access_log off; }
if (!-e $request_filename) { rewrite ^/([a-zA-Z0-9]+)$ /$1/ permanent; rewrite ^/report\.html$ /index.php?c=dingshi&a=report last; rewrite ^/getHit\.html$ /index.php?c=dingshi&a=getHit last; rewrite ^/search\.html$ /index.php?c=index&a=search last; rewrite ^/(xinwen|gonglue)/$ /index.php?c=news&a=index&cat=$1 last; rewrite ^/(xinwen|gonglue)/list_(\d+)_(\d+)\.html$ /index.php?c=news&a=index&cat=$1&tid=$2&page=$3 last; rewrite ^/(xinwen|gonglue)/(\d+)\.html$ /index.php?c=news&a=show&cat=$1&id=$2 last; rewrite ^/(xinwen|gonglue)/(\d+)_(\d+)\.html$ /index.php?c=news&a=show&cat=$1&id=$2&page=$3 last; }
完整的规则如下:
nginx -t //校验规则是否正确 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfu 提示成功的话 重启nginx即可 service nginx restart如果报错可能是添加有误或伪静态规则有误。
以上就是吾爱编程为大家介绍的lnmp伪静态设置方法。
欢迎分享转载→ lnmp伪静态_lnmp伪静态设置方法
permission denied什么意思
(113298)人喜欢 2022-11-30Nginx禁止指定UA访问的方法_nginx屏蔽指定的user_agent
(843)人喜欢 2022-10-25Apache Struts2远程代码执行漏洞(CVE-2020-17530)
(822)人喜欢 2022-10-14Linux下使用ipset封大量IP及ipset参数说明
(962)人喜欢 2022-10-14iptables ipset重启失效_ipset重启生效的方法
(1969)人喜欢 2022-09-27在Windows中配置Rsync同步_windows使用rsync同步文件
(437)人喜欢 2019-12-26© 2015-2021 - 吾爱编程网 版权所有 苏ICP备18033726号-1关于我们 - 网站声明 - 联系我们