2
所以即時嘗試將應用程序從apache移動到NginX,但我發現我需要重新編寫.htaccess文件,我有一個很好的看看,但最後我需要尋求一些幫助。.htaccess nginx重寫規則排除某些文件夾
下面是來自apache的.htaccess文件,我試圖將所有請求重定向到index.php,除了對/ html,/ css,/ images,/ php的請求。
感謝您的幫助提前! 比爾
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 reamin作爲www.domain.com/blah/blah/blah /但加載index.php文件
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;
}
}
感謝湯姆,使用,而研究它讓我看到了轉換器IVE .. 'code' 如果($ REQUEST_FILENAME〜*! 「^(HTML | CSS |圖片| PHP)/」){ \t集$ rule_0 1 $ rule_0; } if($ rule_0 =「1」){ \t rewrite^/(。*)$ /index.php last; '代碼' – Bill