2013-09-16 34 views
1

我使用JS的pushState的事件,并因此改写了我的htaccess以每路径在我的网址重定向到的index.php:htaccess的冲突与AJAX脚本

# html5 pushstate (history) support: 

<ifModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !index 
RewriteRule (.*) index.php [L] 
</ifModule> 

的作品就好了..但是我建立了一个ajax脚本,用于检查某些图像是否可用。

function loadPicture(selector, file, errorf){ 

    $.ajax({url: file,type:'HEAD',error:function(){ 

     $(selector).attr('src', errorf); 

     $('#notavailable').show(); 

    }, success:function(){ 

     $(selector).attr('src', file); 

     if($('#notavailable').is(':visible')){ 

       $('#notavailable').hide(); 

     } 

    }}); 

}; 

此脚本不再工作,我意识到这是因为.htaccess。

现在我真的不是htaccess的专家,我发现它很难理解,可能肯定需要一些帮助。也许有人可以告诉我,我可以如何重定向每个顶级/根路径(例如domain.com/somethingtoredirect)到我的index.php,但对某些甚至每个文件夹都做出例外(domain.com/thisfoldershouldnotificirectedByHtAccess)

I认为这将解决我的问题,因为我检查的图像不存储高层次,但在子文件夹..

任何帮助高度赞赏。

罗马

回答

1

只需从抓排除图片文件夹中的所有规则:

RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^/dummy-image-folder/ [NC] 
RewriteRule^index.php [L] 
+0

太神奇了!我只是不得不离开^而不是它的工作。非常感谢你!!! – user2525589

+0

非常欢迎您,很高兴为您解决问题。 – anubhava