2011-04-30 8 views
23

私はhtaccessのルールをnginxの書き換えに変換する運がありません。私は、NginxRewriteModuleのドキュメントをチェックアウトしていくつかのことを行ってきましたが、もっと複雑なものを私は失っています。htaccessをnginxに変換する

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] 
+0

http://serverfault.com/またはhttp://webmasters.stackexchange.com/のためのより良いです。 –

答えて

9

書き換えルールはほとんどnginxのと同じように書かれている: ルールはあなたにトラブルを引き起こしているhttp://wiki.nginx.org/HttpRewriteModule#rewrite

?ここで私が見てんですよ私はそれらを翻訳するのを助けることができた! nginxの書き換えツールへの.htaccessはApacheを翻訳する

33

オンラインツールが含まれます。これらのツールはifステートメントを使用して同等のrewrite expressionsに変換しますが、彼らがすべきことを

注意をtry_filesに変換されます。参照:

$コンテンツ= $ _POST [ 'コンテンツ':

+3

この1つは私のために働いていないようだが、これはした:http://winginx.com/htaccess –

+0

どちらも私のために働いた。私は非常に基本的な書き換えルールを試しました。 –

+1

私は出力をどこで使うべきですか? PHPファイルですか?私は[this](http://winginx.com/htaccess)を使用していましたが、出力に 'if'が含まれていました。今はどうすればいいのか知りたいですか? –

1

は、あなたが簡単にあなたの古いhtaccessファイルを解析するPHPスクリプトを作ることができ、私はPrestaShopのルールについて、このいずれかを使用しています];

$lines = explode(PHP_EOL, $content); 
    $results = ''; 

    foreach($lines as $line) 
    { 
     $items = explode(' ', $line); 

     $q = str_replace("^", "^/", $items[1]); 

     if (substr($q, strlen($q) - 1) !== '$') $q .= '$'; 

     $buffer = 'rewrite "'.$q.'" "'.$items[2].'" last;'; 

     $results .= $buffer.PHP_EOL; 
    } 

    die($results); 
+12

途方もないまともな答えが軽度のコメントで害されたのは残念です。私はそれを編集しました。 –

+0

この回答は、とにかく素早い解決策として救いの手かもしれませんが、このように書き直さないのが最善です。特に電子商取引のウェブサイトの場合。この文書をお読みくださいhttps://www.nginx.com/resources/wiki/start/topics/examples/likeapache-htaccess/ –

9

まだテストされていませんが、外見はthe oneよりも優れています。 winginx.com/en/htaccess

説明が書かれています:htaccess to nginx converter

について

サービスは設定手順をnginxのためにApacheの.htaccessファイルを変換することです。

まず、サービスはmod_rewriteからnginxへの変換器と考えられていました。しかし、Apacheからnginxに移植する理由がある他の命令を変換することができます。

注意サーバーの指示(例:php_valueなど)は無視されます。

コンバータは、正規表現や論理エラーなどの構文をチェックしません。

ご使用の前に手動で確認してください。

+0

winginx.com/htaccessは動作しません –

+0

昨日、それはすぐにダウンしていることに気付きました。うまくいけば、それはオンラインに戻ります。 –

3

使用この: http://winginx.com/htaccess

オンラインコンバータ、良い方法と時間の節約;)

+2

あなたがよく見れば、私はあなたがそうする前にそのリンク方法を投稿したことを見ることができます。 –

+0

本当の男、申し訳ありません! – ErickXavier

関連する問題