2012-05-07 12 views
2

私はapacheからNginXにアプリケーションを移動しようとしていますが、私は.htaccessファイルを書き直す必要があることを発見しました。いくつかの助けを求める。.htaccess to nginx特定のフォルダを除いてルールを書き直す

以下は、/ html、/ css、/ images、/ phpへのリクエストを除き、すべてのリクエストをindex.phpにリダイレクトしようとしているapacheの.htaccessファイルです。

ご協力いただきありがとうございます。 ビル

RewriteEngine on 
RewriteRule ^html [L,NC] 
RewriteRule ^css [L,NC] 
RewriteRule ^images [L,NC] 
RewriteRule ^php [L,NC] 
RewriteRule ^.*$ index.php [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !directory/(.*)$ 
RewriteCond %{REQUEST_URI} !(.*)$ 
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] 

は、これまでのところ私は以下があり、HTML、CSS、画像やPHPファイルへのリクエストは素晴らしい取り組んでいます。

しかし、私がwww.domain.com/blah/blah/blah/を取得すると、404が得られます。私が本当に望んでいるのは、URLがwww.domain.com/blah/blah/blah /しかし、特定のフォルダ内のコンテンツへのフィルタリング要求のために、これらの線に沿って何かを試してみてください

location ~ directory/(.*)$ { 
} 

location ~ (.*)$ { 
} 

location /html { 
rewrite ^/html/break; 
} 

location /css { 
rewrite ^/css/break; 
} 

location /images { 
rewrite ^/images/break; 
} 

location /php { 
rewrite ^/php/break; 
} 

location/{ 
rewrite ^(.*)$ /index.php break; 
if (!-e $request_filename){ 
rewrite ^(.*)$ http://www.domain.com/$1 redirect; 
} 
} 

答えて

0

index.phpファイルをロードします。

RewriteEngine On 
# if not requesting content in one of the specified folders 
RewriteCond %{REQUEST_FILENAME} !^(html|css|images|php)/ [NC] 
# redirect visitor to the index page 
RewriteRule ^(.*)$ index.php [L,QSA] 

感嘆符を書き換え条件は否定を意味する前に、(!)したがって、要求されたファイル名がhtmlまたはcssまたは....で始まらない場合は、書き換えルールを適用してください。

+0

おかげで、トム、それは私を与える... 'code' かの研究をしながら、見コンバータアイブ使用して($ REQUEST_FILENAME〜*! "^(HTML |画像| | CSSをPHP)/"){ \tセット$ rule_0 1 $ rule_0; } if($ rule_0 = "1"){ \t書き換え^ /(。*)$ /index.php last; } 'code' – Bill

関連する問題