YOURLS (Your Own URL Shortener) 是一款开源的PHP网址缩短服务程序。使用YOURLS你可以轻松建立属于自己的短网址生成系统且可实时查看每一个短网址的访问统计信息。YOURLS官方只提供了apache的伪静态规则,对于使用nginx环境的用户可以使用以下伪静态规则来实现YOURLS完美使用。

YOURLS安装在根目录下:

location /
{if (!-f $request_filename){
    set $rule_0 1$rule_0;
}
if (!-d $request_filename){
    set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
    rewrite ^/([0-9A-Za-z]+)/?$ /yourls-go.php?id=$1 last;
}
    rewrite ^/([0-9A-Za-z]+)\+/?$ /yourls-infos.php?id=$1 last;
    rewrite ^/([0-9A-Za-z]+)\+all/?$ /yourls-infos.php?id=$1&all=1 last;
}

YOURLS安装在子目录下(以go子目录为例)

location /go/
{
if (!-f $request_filename){
   set $rule_0 1$rule_0;
}
if (!-d $request_filename){
   set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/go/([0-9A-Za-z]+)/?$ /go/yourls-go.php?id=$1 last;
}
rewrite ^/go/([0-9A-Za-z]+)\+/?$ /go/yourls-infos.php?id=$1 last;
rewrite ^/go/([0-9A-Za-z]+)\+all/?$ /go/yourls-infos.php?id=$1&all=1 last;
}

备注:请根据YOURLS所在子目录将go修改成你所使用的子目录名称。

Last modification:August 14th, 2020 at 03:01 pm
If you think my article is useful to you, please feel free to appreciate