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