允许在nginx服务器中进行htaccess重定向

时间:2014-03-04 13:44:56

标签: .htaccess nginx

这是我在nginx服务器中的htaccess文件但不能正常工作 我想像下面的url一样运行index.html

http://domain.com//folder1/folder2/?a=af.jpg
   <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /folder1/folder2/
    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.html?/$1 

   </IfModule>

1 个答案:

答案 0 :(得分:1)

请尝试以下规则:

location /folder1/folder2/ {
  if (!-e $request_filename){
    rewrite ^/folder1/folder2/(.*)$ /folder1/folder2/index.html?/$1;
  }
}