2014-08-27 72 views
1

目前,我的.htaccess文件将所有不存在文件的请求路由到index.php。我想改变它,以便它将所有请求路由到index.php,而不管文件是否存在,除了某些目录/路径。 (如/ JS,/ CSS,/ IMG)Apache htaccess - 将所有请求路由到index.php,除了那些到某些目录

这里是我当前的配置:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 
</IfModule> 

我无法搞清楚如何与谷歌或Apache的文档做到这一点。非常感谢帮助,以及有关此问题的任何常规提示。

回答

0

以下应该工作

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 

    RewriteCond %{REQUEST_FILENAME} ! ^/css/ [OR] 
    RewriteCond %{REQUEST_FILENAME} ! ^/img/ [OR] 
    RewriteCond %{REQUEST_FILENAME} ! ^/js/ 
    RewriteRule . /index.php [L] 
</IfModule> 
相关问题