MENU

Short Links:自己的专属多功能跳转页

一直想将自己的域名充分利用起来,除了邮箱。是否可以像 t.cn 那样弄个短网址?
当你看到整篇文章时,我已经找到了自认为最好的解决方案。

Short Links

市面上已有短网址项目要么对新手不友好,要么添加数据操作繁琐,或不易根据自己喜好返回动态链接。自己根据自己的需求写了一个页面,效果还不错,分享给大家。

已实现功能

# 指定后缀KEY
    host.com/baidu => baidu.com
# 子城名
    host.com/blog/hello.html => blog.host.com/hello.html
# 动态链接
    host.com/mail/xxx@gmail => mailto:xxx@gmail.com
# 手气不错
    host.com/random 
        => one.host.com/two.html
        => two.host.com/one.html

安装使用

  1. 前往 GitHub 将所有文件下载并上传到网站根目录
  2. 设置伪静态现则
if (!-e $request_filename) {
  rewrite ^/(?!.well-known)(.*)$ /index.php?$1 last;
}
  1. 根据你的需求修改 index.php 及 env/xxx.ini 文件/代码内容
  2. 访问你的网站域名查看效果

实例演示

1. 指定后缀 KEY

https://hovthen.com/qgroup

本链接为 QQ 群链接,欢迎加入!

点击访问

{
    "Data": {
        "Request": "/qgroup",
        "Type": "link",
        "content": "https://jq.qq.com/?_wv=1027&k=GJim4iGM"
    },
    "Time": "21/11/19 15:29:11"
}
可以在 link.ini 文件中随意添加,但不嫩包含 / 这一符号。位置及格式如下:

[index]
index = https://hovthen.com/home
donate = "https://page.hovthen.com/donate"
KEY = "链接网址"
## 添加到此处,格式如上行

[xxx]
## 不要添加到此处
## 此处为手气不错链接

2. 子域名转换

当包含某些关键词时,自动转换为子域名下的链接。

https://hovthen.com/boke/107

点击访问

{
    "Data": {
        "Request": "/boke/107",
        "Type": "link",
        "content": "https:\/\/boke.hovthen.com/107"
    },
    "Debug": {
        "Host": {
            "self": {
                "code": true,
                "type": "link",
                "data": "https:\/\/boke.hovthen.com/107",
                "full": "https:\/\/boke.hovthen.com/",
                "host": "hovthen.com",
                "domain": "boke.hovthen.com",
                "port": ""
            },
            "friend": {
                "code": false,
            },
            "allow": {
                "code": false,
            },
            "block": {
                "code": false,
            }
        }
    },
    "Time": "21/11/19 14:13:11"
}

3. 动态链接

当包含某些关键词时,根据参数自动获取对应内容。

https://hovthen.com/img_gravatar/hovthen@gmail.com/cn

这个链接可以重定向至邮箱对应的的 Gravatar 头像,由于国内访问速度较慢,还可以添加一个 CDN 标识。

hovthen@gmail.com:个人邮箱地址
cn:CDN节点标识

Gravatar 头像

{
    "Data": {
        "Request": "/img_gravatar/hovthen@gmail.com/cn",
        "Type": "link",
        "content": "https:\/\/cn.gravatar.com/avatar/19c4b5fa624eab877e101380d525f1a0"
    },
    "Debug": {
        "Host": {
            "self": {
                "code": false,
            },
            "friend": {
                "code": false,
            },
            "allow": {
                "code": true,
                "type": "link",
                "data": "https:\/\/cn.gravatar.com/avatar/19c4b5fa624eab877e101380d525f1a0",
                "full": "https:\/\/cn.gravatar.com/",
                "host": "gravatar.com",
                "domain": "cn.gravatar.com",
                "port": ""
            },
            "block": {
                "code": false,
            }
        }
    },
    "Time": "21/11/19 14:02:11"
}

扩展应用

有时,可嫩需要在 Typecho 博客中使用,故还写了一个精简版的 Mirages for Typecho 模板页面。效果如下面几个链接:

后记

有任何疑问欢迎评论,尽量解答。

返回文章列表 文章二维码 打赏
本页链接的二维码
打赏二维码