yourls rewrite apache to nginx

Apache rewrite .htaccess file

# BEGIN YOURLS

RewriteEngine on

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([0-9A-Za-z]+)/?$ /yourls-go.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+/?$ /yourls-infos.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+all/?$ /yourls-infos.php?id=$1&all=1 [L]

# END YOURLS

explain

# BEGIN YOURLS

RewriteEngine on
##This line starts the mod_rewrite module

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
##如果访问的文件存在,就不进行rewrite.
RewriteCond %{REQUEST_FILENAME} !-d
##如果访问的目录存在,就不进行rewrite.

RewriteRule ^([0-9A-Za-z]+)/?$ /yourls-go.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+/?$ /yourls-infos.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+all/?$ /yourls-infos.php?id=$1&all=1 [L]

# END YOURLS

#####Nginx

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

发表评论

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