Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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
Apache 将所有请求重定向到index.php,但/files子目录除外_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache 将所有请求重定向到index.php,但/files子目录除外

Apache 将所有请求重定向到index.php,但/files子目录除外,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,到目前为止,我对.htaccess文件了解很少。我想将所有请求重定向到根文件夹中的一个index.php文件,除非url链接到文件文件夹中存在的文件。(例如example.com/files/picture.png)我只想在根目录中使用htaccess文件,必要时在files目录中使用一个。此外,我不想显示被拒绝许可的消息 现在我有这个: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILE

到目前为止,我对.htaccess文件了解很少。我想将所有请求重定向到根文件夹中的一个index.php文件,除非url链接到文件文件夹中存在的文件。(例如example.com/files/picture.png)我只想在根目录中使用htaccess文件,必要时在files目录中使用一个。此外,我不想显示被拒绝许可的消息

现在我有这个:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
但是如果url引用的文件存在,它不会将一个重定向到index.php文件。有什么帮助吗?我在网上找过,但什么也找不到。

类似这样的东西:

RewriteEngine on

RewriteCond %{REQUEST_URI}  /img/.+(gif|png|jpg)$
RewriteRule .* - [L]

RewriteCond %{REQUEST_URI}  /css/.+(css|png)$
RewriteRule .* - [L]

RewriteCond %{REQUEST_URI}  /js/.+css$
RewriteRule .* - [L]

RewriteCond %{REQUEST_URI}  /js/.+(js|htm)$
RewriteRule .* - [L]

RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
除css javascript和图像文件外,所有请求都将通过index.php文件。这个.htaccess文件是我在codeigniter框架中使用的,所以对于您的情况,它可能会有点不同