Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ApacheHtaccess-将所有请求路由到index.php,但不包括到特定目录的请求_Apache_.htaccess - Fatal编程技术网

ApacheHtaccess-将所有请求路由到index.php,但不包括到特定目录的请求

ApacheHtaccess-将所有请求路由到index.php,但不包括到特定目录的请求,apache,.htaccess,Apache,.htaccess,目前,my.htaccess文件正在将文件不存在的所有请求路由到index.php。我想对此进行修改,以便它将所有请求路由到index.php,而不管该文件是否存在,某些目录/路径除外。(例如/js、/css、/img) 以下是我当前的配置: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] Rewrite

目前,my.htaccess文件正在将文件不存在的所有请求路由到index.php。我想对此进行修改,以便它将所有请求路由到index.php,而不管该文件是否存在,某些目录/路径除外。(例如/js、/css、/img)

以下是我当前的配置:

<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>

重新启动发动机
重写基/
重写条件%{HTTP_HOST}^www\.(.*)$[NC]
重写规则^(.*)$http://%1/$1[R=301,L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]

我很难弄清楚如何使用谷歌或apache的文档来实现这一点。非常感谢您的帮助,以及有关此问题的一般提示。

以下内容应该有用

<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>

重新启动发动机
重写基/
重写条件%{HTTP_HOST}^www\.(.*)$[NC]
重写规则^(.*)$http://%1/$1[R=301,L]
重写cond%{REQUEST_FILENAME}^/css/[或]
重写cond%{REQUEST_FILENAME}^/img/[或]
重写cond%{REQUEST_FILENAME}^/js/
重写规则/index.php[L]