Nginx下Xenforo伪静态代码 去掉index.php
折腾了下xenforo,nginx下,涉及到伪静态,需要去掉“index.php?”,由于xenforo在国内这方面的知识并不多,去官方看了下friendurl,使用里面的代码有点小错误提示502错误。
官方的代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | location /xf/ { try_files $uri $uri/ /xf/index.php?$uri&$args; index index.php index.html; } location /xf/internal_data/ { internal; } location /xf/library/ { internal; } location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } |
里面的/xf 是路径,打个比方,比如安装在pianpai.com的fx目录下,那么就用上面的代码。但是我在使用上面的代码,502.
我的伪静态代码
于是试着删除了部分,只留下下面的代码。
1 2 3 4 | location /xf/ { try_files $uri $uri/ /xf/index.php?$uri&$args; index index.php index.html; } |
于是成功!
操作步骤
1、在这个路径/usr/local/nginx/conf创建xenforo.conf
2、修改/usr/local/nginx/conf/vhost/www.yourwebdomain.conf
帮助:lnmp添加域名会默认生成一个“域名命名的.conf”的文件,比如你的域名是www.hao123.com,那么就是修改/usr/local/nginx/conf/vhost/www.hao123.com.conf
修改参考下图
3、重启lnmp (命令:/root/lnmp restart)
本文想法有参考官方文档:https://xenforo.com/help/friendly-urls/