ga('set', 'anonymizeIp', 1);
Categories: 运维

Xenforo的伪静态规则

今天将Xenforo论坛从UPUPW迁移到另台机器的BT里,UPUPW的N模式其实是前端使用NGINX,后端使用Apache的方式,所以使用的伪静态还是Apache的,BT里我用的是LNMP,所以伪静态规则需要更换,这里记录一下以备日后查找。

Apache的直接使用自带的`.htaccess`文件即可。

Nginx可按以下方式写,只需修改server name, rewrite url, log & root location即可。

```php
server {
listen 80; #port
server_name www.forum.website.com;
# rewrite www, try to keep your internal linking consistent.
rewrite ^ http://forum.website.com$request_uri? permanent;
error_log /var/log/nginx/website.log warn;
root /home/srv/www/website.com/public_html/forum;
#end changes needed to begin

location / {
#This sends everything through index.php and keeps the appended query string intact.
try_files $uri $uri/ /index.php?$uri&$args;
index index.html index.htm index.php;

#gzip it, gzip it good
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_min_length 1100;
gzip_buffers 64 8k;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}

# use fastcgi for all php files
location ~ \.php$ {
# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
try_files $uri /index.php =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

#add some expires
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
log_not_found off;
}

#protect the innocent
location ~ ^/community/(internal_data|library)/(.*)$ {
internal;
}

# deny access to apache .htaccess files
location ~ /\.ht
{
deny all;
}
}
```

madlaxcb

View Comments

    • location添加在网站–设置–伪静态里,server无法直接写在那,可以在网站–设置–配置文件那写,注意备份。

Recent Posts

解决WIN10显示器重启后分辨率变低窗口乱跳问题

  最近换了显示器,当有事离开…

2月 ago

宝塔开启堡塔防入侵会导致Chevereto的Cron运行失败

昨晚给服务器搬迁,新服务器装了…

7月 ago

chevereto V3和V4的改造

今天有空升级了cheveret…

11月 ago

win11开启bbr2

powershell: net…

1年 ago

OVH使用API安装发行版内核的系统(关于API,IPXE,RAID等)

OVH的新面板提供的系统模板比…

1年 ago