htaccess的转换让nginxhtaccess、nginx

2023-09-02 00:19:47 作者:贪恋年华似水终老去

我有没有运气转换htaccess的规则nginx的重写。我已经签出了NginxRewriteModule文档,并有一些工作要做,但更复杂的人,我在一个损失。下面是我在寻找什么:

 重写规则^ $ /cgi-bin/index.cgi [L]
重写规则([0-9A-ZA-Z] {12}) - 德尔 - ([0-9A-ZA-Z] +)/.+$ /cgi-bin/index.cgi?del=$1-$2 [L ]

的RewriteCond%{} REQUEST_FILENAME!-f

重写规则^([0-9A-ZA-Z] {12})( HTML |?)$ /cgi-bin/index.cgi?op=download1&id=$1 [L]
重写规则^([0-9A-ZA-Z] {12})( /.+ |  html的?| $)/cgi-bin/index.cgi?op=download1&id=$1&fname=$2 [L]
重写规则^([0-9A-ZA-Z  -_] {4,64})/([0-9A-ZA-Z] {12})$ /cgi-bin/index.cgi?op=download1& usr_login = $ 1安培; ID = $ 2 [L]
重写规则^([0-9A-ZA-Z  -_] {4,64})/([0-9A-ZA-Z] {12})( /.+ |  html的?| $)/的cgi-bin / index.cgi文件OP =下载1&放大器; usr_login = $ 1安培; ID = $ 2及FNAME = $ 3 [L]

#RewriteRule ^经销商 html的$ /cgi-bin/Templates/Pages/english/Reseller.html [L]
重写规则^ checkfiles  html的$ /cgi-bin/index.cgi?op=checkfiles [L]
重写规则^接触 html的$ /cgi-bin/index.cgi?op=contact [L]
重写规则^ premium  html的$ /cgi-bin/index.cgi?op=payments [L]
重写规则^登录 html的$ /cgi-bin/index.cgi?op=login [L]
重写规则^目录(。*)。HTML $ /cgi-bin/index.cgi?op=catalogue&date=$1 [L]
重写规则^新闻([0-9] *)。HTML $ /cgi-bin/index.cgi?op=news&page=$1 [L]
重写规则^ N([0-9] +) -  *  HTML $ /cgi-bin/index.cgi?op=news_details&news_id=$1 [L]
重写规则^免费([0-9] +)。HTML $ /cgi-bin/index.cgi?op=registration&aff_id=$1 [L]
重写规则^用户/([0-9A-ZA-Z  -_] {4,64})/?([0-9] + | $)/cgi-bin/index.cgi?op=user_public&usr_login= $ 1安培; fld_id = $ 2 [L,NC]
重写规则^ embedmp3  - ([0-9A-ZA-Z] {12}) HTML $ /cgi-bin/index.cgi?op=mp3_embed&file_$c$c=$1 [L]
重写规则^ embedmp4  - ([0-9A-ZA-Z] {12}) HTML $ /cgi-bin/index.cgi?op=mp32_embed&file_$c$c=$1 [L]
重写规则^箱$ /cgi-bin/index_box.cgi [L]

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^([0-9A-ZA-Z  -_] {4,64})(/ [^  /] * / |?$)$ /cgi-bin/index.cgi?op=user_public&usr_login= $ 1安培; FLD = $ 2 [L,NC]

的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^([A-Z0-9   -   _] +)HTML /cgi-bin/index.cgi?op=page&tmpl=$1$2 [L]。(*)
 

解决方案

在线工具翻译的Apache的.htaccess Nginx的重写工具包括:

http://winginx.com/htaccess http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

请注意,这些工具将转换为相当于改写EX pressions 使用如果语句,但他们应该被转换成 try_files 。参见:

http://wiki.nginx.org/NginxHttpCoreModule#try_files 使Nginx服务器支持.htaccess的方法

I'm having no luck converting htaccess rules to nginx rewrite. I've checked out the NginxRewriteModule documentation and have a few done, but the more complicate ones I'm at a loss for. Here's what I'm looking at:

RewriteRule    ^$                                               /cgi-bin/index.cgi [L]
RewriteRule    ([0-9A-Za-z]{12})-del-([0-9A-Za-z]+)/.+$         /cgi-bin/index.cgi?del=$1-$2 [L]

RewriteCond     %{REQUEST_FILENAME} !-f

RewriteRule    ^([0-9A-Za-z]{12})(.html?|$)$                   /cgi-bin/index.cgi?op=download1&id=$1 [L]
RewriteRule    ^([0-9A-Za-z]{12})(/.+|.html?|$)               /cgi-bin/index.cgi?op=download1&id=$1&fname=$2 [L]
RewriteRule    ^([0-9A-Za-z-_]{4,64})/([0-9A-Za-z]{12})$   /cgi-bin/index.cgi?op=download1&usr_login=$1&id=$2 [L]
RewriteRule    ^([0-9A-Za-z-_]{4,64})/([0-9A-Za-z]{12})(/.+|.html?|$)        /cgi-bin/index.cgi?op=download1&usr_login=$1&id=$2&fname=$3 [L]

#RewriteRule    ^Reseller.html$                                         /cgi-bin/Templates/Pages/english/Reseller.html [L]
RewriteRule    ^checkfiles.html$                                       /cgi-bin/index.cgi?op=checkfiles [L]
RewriteRule    ^contact.html$                                          /cgi-bin/index.cgi?op=contact [L]
RewriteRule    ^premium.html$                                          /cgi-bin/index.cgi?op=payments [L]
RewriteRule    ^login.html$                                            /cgi-bin/index.cgi?op=login [L]
RewriteRule    ^catalogue(.*).html$                                    /cgi-bin/index.cgi?op=catalogue&date=$1 [L]
RewriteRule    ^news([0-9]*).html$                                     /cgi-bin/index.cgi?op=news&page=$1 [L]
RewriteRule    ^n([0-9]+)-.*.html$                                     /cgi-bin/index.cgi?op=news_details&news_id=$1 [L]
RewriteRule    ^free([0-9]+).html$                     /cgi-bin/index.cgi?op=registration&aff_id=$1 [L]
RewriteRule    ^users/([0-9A-Za-z-_]{4,64})/?([0-9]+|$)        /cgi-bin/index.cgi?op=user_public&usr_login=$1&fld_id=$2 [L,NC]
RewriteRule    ^embedmp3-([0-9A-Za-z]{12}).html$   /cgi-bin/index.cgi?op=mp3_embed&file_code=$1 [L]
RewriteRule    ^embedmp4-([0-9A-Za-z]{12}).html$   /cgi-bin/index.cgi?op=mp32_embed&file_code=$1 [L]
RewriteRule    ^box$                                    /cgi-bin/index_box.cgi [L]

RewriteCond     %{REQUEST_FILENAME} !-f
RewriteCond     %{REQUEST_FILENAME} !-d
RewriteRule    ^([0-9A-Za-z-_]{4,64})(/[^/]*/?|$)$            /cgi-bin/index.cgi?op=user_public&usr_login=$1&fld=$2 [L,NC]

RewriteCond     %{REQUEST_FILENAME} !-f
RewriteRule    ^([a-z0-9-_]+).html(.*)                        /cgi-bin/index.cgi?op=page&tmpl=$1$2 [L]

解决方案

Online tools to translate Apache .htaccess to Nginx rewrite tools include:

http://winginx.com/htaccess http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

Note that these tools will convert to equivalent rewrite expressions using if statements, but they should be converted to try_files. See:

http://wiki.nginx.org/NginxHttpCoreModule#try_files