2011-09-26 159 views
2

我爲Magento插件獲得了以下.htaccess代碼,有人可以幫我將它轉換爲有效的Nginx重寫嗎?我正在經歷一段非常艱難的時期。這是一個重寫和緩存Magento URL的插件。將Apache .htaccess轉換爲Nginx

該模塊的原始編輯器不能幫助我。我確定有很多人使用Nginx並想使用這個插件功能!

# static rewrite - home page 
RewriteCond %{HTTP_COOKIE} store=default 
RewriteCond %{HTTP_COOKIE} !artio_mturbo=.* 
RewriteCond %{REQUEST_URI} ^/magento/$ 
RewriteCond %{QUERY_STRING} !.+ 
RewriteCond /var/ww/var/turbocache/default.html -f 
RewriteRule .* var/turbocache/default.html [L] 

# static rewrite - other pages 
RewriteCond %{HTTP_COOKIE} store=default 
RewriteCond %{HTTP_COOKIE} !artio_mturbo=.* 
RewriteCond %{REQUEST_URI} /magento/(.*)\.html$ [NC] 
RewriteCond %{QUERY_STRING} !.+ 
RewriteCond /var/www/var/turbocache/magento/default/%1.html -f 
RewriteRule .* var/turbocache/magento/default/%1.html [L] 

# store view is choosen by request_path 

# static rewrite - home page 

RewriteCond %{HTTP_COOKIE} !artio_mturbo=.* 
RewriteCond %{REQUEST_URI} ^/magento/default(/|)$ 
RewriteCond %{QUERY_STRING} !.+ 
RewriteCond /var/www/var/turbocache/default.html -f 
RewriteRule .* var/turbocache/default.html [L] 

# static rewrite - other pages 
RewriteCond %{HTTP_COOKIE} !artio_mturbo=.* 
RewriteCond %{REQUEST_URI} ^/magento/default/(.*)\.html$ [NC] 
RewriteCond %{QUERY_STRING} !.+ 
RewriteCond /var/www/var/turbocache/magento/default/%1.html -f 
RewriteRule .* var/turbocache/magento/default/%1.html [L] 

#cookie 
RewriteCond %{HTTP_COOKIE} !artio_mturbo=.* 
RewriteCond %{REQUEST_URI} ^/magento/$ 
RewriteCond %{QUERY_STRING} !.+ 
RewriteCond /var/www/var/turbocache/default.html -f 
RewriteRule .* var/turbocache/default.html [L] 

# rules for default storeview 

# static rewrite - home page 

RewriteCond %{HTTP_COOKIE} !artio_mturbo=.* 
RewriteCond %{REQUEST_URI} /magento/(.*)\.html$ [NC] 
RewriteCond %{QUERY_STRING} !.+ 
RewriteCond /var/www/var/turbocache/magento/default/%1.html -f 
RewriteRule .* var/turbocache/magento/default/%1.html [L] 

到目前爲止感謝!

回答

1

這是一個converter,它可以從你的htaccess中爲你提供這個功能。這可能會給你一個堅實的第一基地。之後,如果您有進一步的問題,請隨時寫下。

+0

我得到的東西從後面轉換器,但它似乎並沒有給我回我需要什麼?我看到一些變種,但它似乎不能轉化爲我所需要的,或者我在這裏理解了不正確的東西? – Tom

3
if ($http_cookie ~ "store=default"){ 
    set $rule_0 1$rule_0; 
} 
if ($http_cookie !~ "artio_mturbo=.*"){ 
    set $rule_0 2$rule_0; 
} 
if ($uri ~ "^/magento/$"){ 
    set $rule_0 3$rule_0; 
} 
if ($args !~ ".+"){ 
    set $rule_0 4$rule_0; 
} 
if (-f /var/ww/var/turbocache/default.html){ 
    set $rule_0 5$rule_0; 
} 
if ($rule_0 = "54321"){ 
    rewrite /.* /var/turbocache/default.html last; 
} 
if ($http_cookie ~ "store=default"){ 
    set $rule_1 1$rule_1; 
} 
if ($http_cookie !~ "artio_mturbo=.*"){ 
    set $rule_1 2$rule_1; 
} 
if ($uri ~* "/magento/(.*).html$"){ 
    set $rule_1 3$rule_1; 
} 
if ($args !~ ".+"){ 
    set $rule_1 4$rule_1; 
} 
if (-f /var/www/var/turbocache/magento/default/%1.html){ 
    set $rule_1 5$rule_1; 
    set $bref_1 $1; 
} 
if ($rule_1 = "54321"){ 
    rewrite /.* /var/turbocache/magento/default/$bref_1.html last; 
} 
if ($http_cookie !~ "artio_mturbo=.*"){ 
    set $rule_2 1$rule_2; 
} 
if ($uri ~ "^/magento/default(/|)$"){ 
    set $rule_2 2$rule_2; 
} 
if ($args !~ ".+"){ 
    set $rule_2 3$rule_2; 
} 
if (-f /var/www/var/turbocache/default.html){ 
    set $rule_2 4$rule_2; 
} 
if ($rule_2 = "4321"){ 
    rewrite /.* /var/turbocache/default.html last; 
} 
if ($http_cookie !~ "artio_mturbo=.*"){ 
    set $rule_3 1$rule_3; 
} 
if ($uri ~* "^/magento/default/(.*).html$"){ 
    set $rule_3 2$rule_3; 
} 
if ($args !~ ".+"){ 
    set $rule_3 3$rule_3; 
} 
if (-f /var/www/var/turbocache/magento/default/%1.html){ 
    set $rule_3 4$rule_3; 
    set $bref_1 $1; 
} 
if ($rule_3 = "4321"){ 
    rewrite /.* /var/turbocache/magento/default/$bref_1.html last; 
} 
if ($http_cookie !~ "artio_mturbo=.*"){ 
    set $rule_4 1$rule_4; 
} 
if ($uri ~ "^/magento/$"){ 
    set $rule_4 2$rule_4; 
} 
if ($args !~ ".+"){ 
    set $rule_4 3$rule_4; 
} 
if (-f /var/www/var/turbocache/default.html){ 
    set $rule_4 4$rule_4; 
} 
if ($rule_4 = "4321"){ 
    rewrite /.* /var/turbocache/default.html last; 
} 
if ($http_cookie !~ "artio_mturbo=.*"){ 
    set $rule_5 1$rule_5; 
} 
if ($uri ~* "/magento/(.*).html$"){ 
    set $rule_5 2$rule_5; 
} 
if ($args !~ ".+"){ 
    set $rule_5 3$rule_5; 
} 
if (-f /var/www/var/turbocache/magento/default/%1.html){ 
    set $rule_5 4$rule_5; 
    set $bref_1 $1; 
} 
if ($rule_5 = "4321"){ 
    rewrite /.* /var/turbocache/magento/default/$bref_1.html last; 
} 

希望它會工作,好運氣。