admin avatar

vanillaforums伪静态规则和memcached缓存的方法

🕟 by admin





vanillaforums伪静态规则

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
.htaccess file:

# Modified
# If you modify this file then change the above line to: # Modified

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Certain hosts may require the following line.
    # If vanilla is in a subfolder then you need to specify it after the /.
    # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
    RewriteBase /forum

    RewriteCond %{QUERY_STRING} ^p=/?([^&]+)(&([^?]+))?$
    RewriteRule ^index\.php %1?%3 [E=X_REWRITE:1,L]

    # The basic rewrite rule.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [QSA,E=X_REWRITE:1,E=X_PATH_INFO:/$1,L]

    # Add the proper X_REWRITE server variable for rewritten requests.
    RewriteCond %{ENV:REDIRECT_X_REWRITE} .+
    RewriteCond %{ENV:REDIRECT_X_PATH_INFO} (.+)
    RewriteRule ^index\.php - [QSA,E=X_REWRITE:1,E=!REDIRECT_X_REWRITE,E=X_PATH_INFO:%1,E=!REDIRECT_X_PATH_INFO,L]

    # 301 redirect urls that start with index.php
    #RewriteCond %{REQUEST_METHOD} GET [NC]
    #RewriteCond %{REQUEST_URI} ^(.*?)/index\.php(.*)$
    #RewriteRule ^index\.php /%1%2 [QSA,R,L]
</IfModule>

nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
location ~* /\.git { deny all; return 403; }
    location /build/ { deny all; return 403; }
    location /cache/ { deny all; return 403; }
    location /cgi-bin/ { deny all; return 403; }
    location /uploads/import/ { deny all; return 403; }
    location /conf/ { deny all; return 403; }
    location /tests/ { deny all; return 403; }
    location /vendor/ { deny all; return 403; }
    location ~* \.php(/|$) {
        rewrite ^ /index.php$uri last;
    }

    # Default path handling
    location / {
        try_files $uri @vanilla;
    }
    
    location @vanilla {
        rewrite ^ /index.php$uri last;
    }

memcached 缓存,添加下面代码到网站根目录下到config.php文件中

1
2
3
4
5
6
7
8
9
10
$Configuration['Cache']['Enabled'] = true;
$Configuration['Cache']['Method'] = 'memcached';
$Configuration['memcached']['Store'] = '127.0.0.1';
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_COMPRESSION] = true;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_DISTRIBUTION] = Memcached::DISTRIBUTION_CONSISTENT;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_LIBKETAMA_COMPATIBLE] = true;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_NO_BLOCK] = true;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_TCP_NODELAY] = true;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_CONNECT_TIMEOUT] = 1000;
$Configuration['Cache.Memcached.Option.'.Memcached::OPT_SERVER_FAILURE_LIMIT] = 2;





💘 相关文章


📝 有偿服务

• 服务器合租380/年
• 服务器配置:2.4G,6核12线程
• nvme raid 1硬盘
• 不提供服务器自主面板
• 适合稳定的个人博客
• 提供备份服务,备份空间自备
• 只提供ipv6地址,搭配cloudflare使用
• 提供想要安装的程序和域名
• 博客必须是和谐健康的
• 博客不能是视频和图片站
• 提供以下付费服务
• 建站,FTP,备份,Linux,Wordpress等建站问题咨询管理
• 加微信:344452500(不闲聊,直接说事)

写一条评论

Based on Golang + fastHTTP + sdb | go1.16.8 Processed in 0ms