跳转程序 YOURLS 的 Apache、Nginx 伪静态规则

一、YOURLS Apache Rewrite 伪静态规则

1、安装在根目录下:

# BEGIN YOURLS

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /yourls-loader.php [L]

# END YOURLS

2、安装在子目录下:

# BEGIN YOURLS

RewriteEngine On
RewriteBase /子目录/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /子目录/yourls-loader.php [L]

# END YOURLS

3、使用不是 www 开头的域名:

# BEGIN WithoutWWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yourls\.org$ [NC]
RewriteRule ^(.*)$ http://yourls.org/$1 [R=301,L]
# END WithoutWWW

二、YOURLS Nginx Rewrite 伪静态规则

1、安装在根目录下:

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;
}

2、安装在子目录下

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]+)/?$ /url/yourls-go.php?id=$1 last;
}
rewrite ^/子目录/([0-9A-Za-z]+)\+/?$ /url/yourls-infos.php?id=$1 last;
rewrite ^/子目录/([0-9A-Za-z]+)\+all/?$ /url/yourls-infos.php?id=$1&all=1 last;
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注