你的位置:首页 > 服务器类

YOURLS apache和nginx伪静态规则

2012-03-23 浏览:(25160) 服务器类 评论(0)

一、Apache YOURLS 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 /somedir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /somedir/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

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

  • 发表评论
  • 查看评论
【暂无评论!】

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。