IPS Community Suite 4.2.6 可用的 Nginx 重写规则

本文给出 IPS Community Suite 4.2.6 可用的 Nginx 重写规则。

在 IPS Community Suite 后台,可以直接下载 Apache 的重写规则,但是没有对 Nginx 支持太好,所以,就需要根据自己的情况,写下适用于 Nginx 的重写规则了。

This post will give you a sample about how to config your IPS Community Suite SEO Urls on Nginx .

IPS Community Suite Nginx rewrite rules as following:

server{
listen 80; #listen end
server_name 你的域名;
index index.html index.htm index.php;
#set $subdomain '';
#root  /home/wwwroot/html/$subdomain;
#或者直接写绝对路径
root  /home/wwwroot/html/你的域名;
# 包含其它 Nginx 配置,一般是 fastcgi 相关的配置文件
#include /home/**/other.conf; #rewrite end
# Set up rewrite rules.
location / {
# index  index.php;
try_files  $uri $uri/ /index.php;
# 下面的也行
# try_files $uri $uri/ /index.php?$args;
}
location ~^(/page/).*(.php)$ {
try_files  $uri $uri/ /index.php;
}
# Stub Status module
location /server_status {
# stub_status on;
#allow 127.0.0.1;
#deny all;
}
# GZIP static content not processed by IPB.
gzip  on;
gzip_static on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript application/xml application/xml+rss text/javascript application/javascript text/x-js;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6].(?!.*SV1)";
# IP.Board PHP/CGI Protection
location ~^(/uploads/).*(.php)$ {
deny     all;
}
location ~^(/hooks/).*(.php)$ {
deny     all;
}
location ~^(/cache/).*(.php)$ {
deny     all;
}
location ~^(/screenshots/).*(.php)$ {
deny     all;
}
location ~^(/downloads/).*(.php)$ {
deny     all;
}
location ~^(/blog/).*(.php)$ {
deny     all;
}
location ~^(/public/style_).*(.php)$ {
deny     all;
}
# Caching directives for static files.
location ~^(/uploads/profile/).*.(jpg|jpeg|gif|png)$ {
access_log off;
expires    1d;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml|htm|txt|swf|cur)$ {
access_log off;
expires    1w;
}
#error_page
error_page 400 /ErrorPages/400.html;
error_page 403 /ErrorPages/403.html;
error_page 404 /ErrorPages/404.html;
error_page 502 /ErrorPages/502.html;
location ~ /ErrorPages/(400|401|403|404|405|502|503)\.html$
{
root /home/wwwroot/lnmp02/domain/bbs/web;
}
location ~ .*\.php$
{
# 如果你在Ubuntu 或者 LinuxMint 上安装,可能如此
fastcgi_pass  unix:/run/php7.0-fpm.sock;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_param DOCUMENT_ROOT  /home/wwwroot/html/你的域名;
fastcgi_param SCRIPT_FILENAME  /home/wwwroot/html/你的域名$subdomain$fastcgi_script_name;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$
{
expires      30d;
}
location ~ .*\.(js|css)$
{
expires      12h;
}
# 不要日志
access_log off;
error_log /dev/null;
}

 

按自己的 Nginx 和网站的路径配置,改写下上面的规则,然后在使用 Nginx 检查重写规则后,重载即可。

you may modify the above rules according your Nginx and the directory of your IPS ,then check rules via Nginx, and reload it.

sudo nginx -t
sudo nginx reload

一条评论

留下评论